How to Set Short URLs in Jekyll with Github Pages03 Apr 2014
In this post, I will describe how to make the URLs for your blog posts (what Jekyll calls permalinks) short and minimal. For example, I wanted the URL for this post to be joshualande.com/short-urls-jekyll without any tags, dates, or other extra characters. This url is short, looks nice, and is easy to share. I also read some speculation that smaller URLs help with SEO.
The Jekyll documentation,
discusses the ability to set permalink to
none in the
But this created URLs like joshualande.com/short-urls-jekyll.html and I didn’t want my URLs ending in “.html”.
Next, I tried setting the permalink value to “/:title” in
This appeared to work, but broke the static pages I had setup (like joshualande.com/about). I could move all the static pages to just be blog posts, but that would have broken my archive of blog posts which should not include static pages.
Finally, I realized that I could get my desired result without messing
up static pages by explicitly setting the
in the YAML metadata of each post. For this post, I set:
It is unfortunate that you have to explicitly set this at the top of each blog post. But this does work, giving me beautiful URLs like joshualande.com/short-urls-jekyll. Please comment below if you know of a simpler way to way to do this.
Finally, if you already have existing permalinks and want them to redirect to your new url, you can do this by following the instructions on this blog post.