Middleman-blog: Where do archive templates go, and what are they called?

I wanted to use Middleman for blogging with middleman-blog. The docs say that you can set blog.calendar_template to a template name (without extension) of the template to use for archive pages.
I’ve set the option to “archive”, but Middleman will always complain on build with:

Error reloading Middleman: Path 2014.html proxies to unknown file archive:[]

I’ve tried placing my template in the following locations:

  1. source/archive.html.erb
  2. source/articles/archive.html.erb
  3. source/layouts/archive.html.erb

But none of the paths work. Where does Middleman (or the blog extension) expect these to go?

Try source/layouts/archive.erb (templates does not correspond to pages, so they do not use the .html suffix)

The same error happens :frowning:

Also, if you look at the default config.rb from the blog extension, you see they use a .html suffix there, even though the documentation says NOT to use any suffixes (?):

https://github.com/middleman/middleman-blog/blob/master/lib/middleman-blog/template/config.tt

I’m really confused about how to get this to work. .erb, .html, .erb.html, .html, those seem not to work.

Ah, some more random fiddling and now it seems to work! The archive file needs to be called e.g. archive.html.erb, needs to be in the root level of your source, but the configuration needs to point only at archive.html (no path, no prefix, no suffix, just that filename). Phew.

Could you point out where in the documentation (http://middlemanapp.com/basics/blogging/) it says to not use extension? Specifically, it should say to omit templating extensions, not the content extension.

archive.html.erb does not need to be in the root of your source, it can be anywhere. So for example if you had it in source/articles/archive.html.erb, you would simply set blog.calendar_template = 'articles/archive.html'.

You can look at your meta pages at http://localhost:4567/__middleman/sitemap/ to better understand how Middleman understands your project.

Apologies for reviving an old topic, but I want to document this.

It appears that the problem is that the blogging extension (as of 4.0.0 and earlier versions) can not find blog templates in the ‘layouts’ directory. Thus:

blog.month_template = "foo.html"           # 'foo.html.erb' in 'source/'
blog.month_template = 'articles/foo.html"  # 'foo.html.erb' in 'source/articles/'

both work without problems. However:

blog.month_template = "foo.html"         # 'foo.html.erb' in 'source/layouts/'
blog.month_template = "layouts/foo.html" # 'foo.html.erb' in 'source/layouts/'

both fail with the message “… proxies to unknown file”.

Based on my experiments, it seems that there’s something very specific about the ‘layouts’ directory that means that the blogging extension is unable to resolve it correctly. So @psyq and @bhollis are both at least partly correct; @psyq is right that putting the template in ‘layouts’ doesn’t work, but @bhollis is right that templates can be placed and referenced anywhere (except ‘layouts’!)

My compromise solution has been to place the blog templates in a folder named ‘layouts_blog’, which keeps the root directory uncluttered and appears to get around this odd limitation.