Renaming, Redating Blog Posts
Here’s a few tips regarding renaming and redating posts and pages in Octopress.
How file names and metadata work in Octopress
- Metadata,
title
anddate
, in the post headers affects how the page displays on the website, and is used for deployment. - The actual filename is for the author’s convenience and is what goes into github.
- You can change the filename any time. The generator does not care. Git will pick up the changes automatically.
- However, if you change the
title
ordate
, then you need to worry about whether one of these conditions exists where you need to create an alias for the old link.- You posted the article, such as Twitter, or you emailed somebody a link to it.
- You have other articles that reference the article being changed.
- If you don’t put in an alias, you’ll get a 404 error and an unhappy reader.
Blogs vs. Pages
- Blog articles are created in a directory structure based on the
date
metadata. - Pages are created where you put them.
Moving a post/page that you already published
- Follow the instructions here to use: jekyll/jekyll-redirect-from
- For any post/page that moves, simply put in this info info in the header of
the post. A couple points:
- You need to put in the
/index.html
at the end. If you don’t do that, nothing happens in terms of generating an alias. - Use the path within the website, such as this example.
- You need to put in the
redirect_from: /blog/2013/05/08/saner-rails-logging/index.html
I had tweeted about the following post so I wanted to make sure the old link still worked. I added the above alias to the blog post for the old link.
- Here’s the old link: http://www.railsonmaui.com/blog/2013/05/08/saner-rails-logging/
- Here’s the new link: http://www.railsonmaui.com/blog/2013/05/08/strategies-for-rails-logging-and-error-handling/
You can click on the old link to see that it takes you to the new link. Ha! No 404!
Redate Rake Task
Here’s an addition to an Octopress Rakefile to rename blog postings to correspond to dates. This rake task does not change the title part. You can do that manually by changing both the title metadata and the name of the file. Note, be sure to comment out line 12 if you are using org-mode.