I have been trying to debug this for days now and this has been very frustrating. I tried going deep into middleman-blog’s innards but I am still lost. Anyway I have been following this
https://middlemanapp.com/basics/blogging/#listing-articles
to the dot, except that I am using HAML and markdown.
I think I’ve customised it way too much? HEre is my config:
page '/*.xml', layout: false
page '/*.json', layout: false
page '/*.txt', layout: false
page "/coffee/*", layout: 'article'
page "/code/*", layout: 'article'
activate :directory_indexes
activate :blog do |blog|
blog.layout = 'article'
blog.sources = "{category}/{title}.html.md"
blog.permalink = "{category}/{title}/"
end
So I have put my posts in
/source/code/middleman.html.md
and they ACTUALLY do appear when I go to: http://10.1.1.59:4567/code/middleman. Problem is, in my layouts/article.haml
I have this:
= blog.articles[0...5].each do |article|
%article
%h1
%a{href: article.url}= article.title
%time= article.date.strftime('%b %e %Y')
= article.summary
%a{href: article.url} Read more
Nothing shows up. I tried doing a binding.pry and blog always returns an empty BlogData object. I have tried doing a bunch of puts by doing a bundle open but I couldn’t understand why it can’t find the damn articles. I’m pretty sure I’m missing something SUPER obvious here as I have tried this exact setup without HAML and it works.
Upon further investigation, it looks like it is the problem of categories as permalinks. So I want my blog to be something like:
http://mydomain.com/category/title/
so I had this setup on a new mdidleman blog:
blog.layout = 'layout'
blog.sources = "/{category}/{title}.html.md"
blog.permalink = "/{category}/{title}/"
article is now located at:
/source/code/example-article.html.md
with code
being my category. Again, it redners no articles. What is it with categories as permalinks that break stuff?