Second blog can't find posts [SOLVED]

I have defined two blogs in config.rb:

activate :blog do |blog|
  blog.name = "notes"
  blog.prefix = "notes"
  blog.custom_collections = {
    category: {
      link: '/categories/{category}.html',
      template: '/notes_category.html'
    }
  }

  blog.permalink = "{year}/{month}/{day}/{title}.html"
  blog.sources = "{year}-{month}-{day}-{title}.html"
  blog.layout = "post"
  blog.summary_separator = /(READMORE)/
  blog.summary_length = 250
  blog.year_link = "{year}.html"
  blog.month_link = "{year}/{month}.html"
  blog.day_link = "{year}/{month}/{day}.html"
  blog.default_extension = ".markdown"
  blog.calendar_template = "calendar.html"
end

activate :blog do |blog|
  blog.name = "essays"
  blog.prefix = "essays"
  blog.permalink = "{year}/{month}/{day}/{title}.html"
  blog.custom_collections = {
    category: {
      link: '/categories/{category}.html',
      template: '/essays_category.html'
    }
  }
  blog.sources = "{year}-{month}-{day}-{title}.html"
  blog.layout = "essay"
  blog.summary_separator = /(READMORE)/
  blog.summary_length = 250
  blog.year_link = "{year}.html"
  blog.month_link = "{year}/{month}.html"
  blog.day_link = "{year}/{month}/{day}.html"
  blog.default_extension = ".markdown"
  blog.calendar_template = "calendar.html"
end

The first blog works, the second does not and I can’t understand why. The links layouts and everything else works. The directories are properly structures, but the listing of “essays” is empty, even though there are 4 articles in the “source/essays” directory. Any ideas where to look?

Regards,

P.

How are you getting the data from the blogs in your tempates? You should use blog('notes') and blog('essays') to retrieve the different blog articles (and tags and such).

Thanks for the reply @tomrutgers !

I’m using HAML. This is my “_latest_feeds.haml” partial which gets displays properly the ‘notes’ but not the ‘essays’:

/ Display multiple Blog posts
#frontblog
  %h1.section
    Notes
    %a.inline{:href => '/feed-notes.xml'}
      %i.fa.fa-rss
  - blog('notes').articles[0...10].each do |article|
    %p.hpost
      %i.fa.fa-pencil
      = link_to article.title, article.url
      %span{:class => "frdate"}
        %time{:datetime => "#{article.date.strftime('%Y-%m-%d %H:%M')}"}= article.date.strftime('%Y %b %d')
  %p.meta_inline{style: 'margin-left: 5%;'}
    %i.fa.fa-arrow-right
    = link_to 'browse notes archive', '/notes.html'
  %br
  %h1.section
    Essays
    %a.inline{:href => '/feed-essays.xml'}
      %i.fa.fa-rss
  - if blog('essays').articles.size > 2
    - blog('essays').articles[0...3].each do |essay|
      %p.hpost
        %i.fa.fa-leaf
        = link_to essay.title, essay.url
        %span{:class => "frdate"}
          %time{:datetime => "#{essay.date.strftime('%Y-%m-%d %H:%M')}"}= essay.date.strftime('%Y %b %d')
  -else
    - blog('essays').articles.each do |essay|
      %p.hpost
        %i.fa.fa-leaf
        = link_to essay.title, essay.url
        %time{:datetime => "#{essay.date.strftime('%Y-%m-%d %H:%M')}"}= essay.date.strftime('%Y %b %d')
  %p.meta_inline{style: 'margin-left: 5%;'}
    %i.fa.fa-arrow-right
    = link_to 'browse essays archive', '/essays.html'

The “feed-essays.xml” is exactly the same as the “feed-notes.xml” apart from the fact that builds the field from “essays”.

The essays_category template:

- listing = [];blog('essays').articles.each {|a| listing << a if a.metadata[:page]['category'] == category }
.container
  %h1.section
    = "Listing essays in category: #{category}"
  %br
  - listing.each do |essay|
    .container
      %post
        %i.fa.fa-pencil
        = link_to essay.title, essay.url
        %p.meta_inline
          = essay.date.strftime('%d %b %Y  %H:%M')

I’ve spent quite some time trying to figure out what I’m doing wrong, where the difference is between the two, but can’t see any real difference.

After a bit of debugging, I noticed that about 40% of posts in notes blogs are part of “blog(‘notes’).articles” object. The other 60% is not displayed. The “blog(‘essays’)” exists but has no articles. Since I’m upgrading from v3, I wonder if there is something obvious missing from the Markdown posts that are not visible.

The problem was that some files had extension .markdown while we need .html.markdown for posts to be properly rendered.

Thanks for the help!

Command to rename files:

for i in $(ls -1|grep -v html);do mv $i ${i%.*}.html.markdown ; done

1 Like

Excellent debugging :sweat_smile:. Glad you figured it out.