I'm using the Middleman Blog gem for my site, but by default it appears the blog articles need to be located in /source
which isn't particularly nice when looking at the tree in vim and trying to locate one of the other files in there (a template for instance).
From looking at the documentation I can't see if there is any way of moving the blog articles so they are stored somewhere else such as a blog_articles
folder or similar.
Is this possible?
Put the following in your config.rb file.
activate :blog do |blog|
blog.permalink = ":year-:month-:day-:title.html"
blog.sources = "blog_articles/:title.html"
end
Assuming you have a post 2012-01-01-example-article.html.markdown
stored in the folder source/blog_articles
.
You should now see the post with this URL: http://localhost:4567/2012-01-01-example-article.html
. (You might have to restart middleman when changing the config.rb
file.)
Please note that I also had to set blog.permalink
, the blog.sources
setting alone didn't do the trick.
A bonus tip: I have activate :directory_indexes
in my config.rb
file. This setting gives you nice looking URLs, without the .html
part.
If you want the same for your blog posts you can drop the .html
from your blog.permalink
setting. Like so:
activate :blog do |blog|
blog.permalink = ":year-:month-:day-:title"
blog.sources = "blog_articles/:title.html"
end
Now you can see your post with this URL: http://localhost:4567/2012-01-01-example-article
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With