What template file is used by middleman-blog for article detail

I’m exploring middleman-blog and can’t seem to fix an issue that I believe I might have somehow introduced. I have a blog list page working, styled and everything but if I click into the link to view just the article the output is dropping some of my fields. I’m trying to determine which html.erb template file is being used to build this view but I can’t find it.

The file I have edited for the blog list is index.html.erb and I was thinking this was being reused for the single article display too but I’ve added some debug copy to that page and even in the full source I can’t find it so I don’t believe that template is being use.

Please help, frustrated middleman-blog newbie.

Thanks!

It would seem that this is by default because I just created a new initial blog and noticing the same odd article detail page (it’s just showing the copy, dropping things like title, date, author, categories/tags/etc.

There must be a template getting used to build these pages but I can’t seem to find it documented anywhere.

Try this. In config.rb:

activate :blog do |blog|
     ...
blog.layout = "blog"
...
end

Then add a blog.haml template in your layout directory.

My config.rb already has a layout defined (while named layout, it has the blog markup). It’s the only layout file I have in use right now.

Here is my blog activation block:

activate :blog do |blog|
  blog.sources = "articles/:year/:month/:day-:title.html"

  blog.layout = "layout"

  blog.new_article_template = "source/articles/article.tt"

  blog.tag_template = "tag.html"
  blog.calendar_template = "calendar.html"

  # Enable pagination
  blog.paginate = true
  blog.per_page = 10
  blog.page_link = "page/{num}"

  blog.custom_collections = {
    category: {
      link: 'categories/{category}.html',
      template: 'category.html'
    }
  }
end

This layout is being properly wrapped around my listing page (which is using index.html.erb), my tags page (tags.html.erb), and my categories page (categories.html.erb). What isn’t working is when I click into the detail of a blog post/article what is showing isn’t correct, it’s just outputting the article body.

My question was, is middleman-blog using a file like index.html.erb that I can specify in the activation configuration and style accordingly? Something like article.html.erb?

So to summarize:

  • Navigating to http://localhost:4567/ renderings my blog layout properly, uses index.html.erb to show a listing page. These articles are intentionally truncated (and paged).
  • Navigating to http://localhost:4567/2012/01/01/example-article/ however renders the article wrapped in the proper layout but does not display the article correctly (just showing body).

Hope that helps explain my issue a bit better. I’ve actually received your suggestion twice now (co-worker suggested this: https://gist.github.com/jzajac/9571ace9b1d673989397.

Thanks!

So I got this working. Started thinking about the blog.template setting suggested to me more then once. Turns out that the layout.erb was being loaded by Middleman by default (duh!), using the nested template I created a blog.erb, refreshed an article page and it’s working.

Thanks!

1 Like