jekyll-clean-urls

jekyll-clean-urls

Clean URLs in Jekyll 2.x (now included Jekyll 3 core)

jekyll-clean-urls

This jekyll plugin allows for clean URLs of the form /:title (with no trailing slash or ".html" extension). This is done by creating destination files of the form /:title.html, but URLs of the form /:title. Your webserver must be configured to serve these files using something like apache's multiviews or with an nginx config similar to:

location / {
  try_files $uri $uri/ $uri.html =404;
}

Usage

Drop this plugin into your _plugins directory. There are no new configuration options. Instead, just specify a permalink setting that does not include a trailing slash or file extension:

permalink: /:year/:month/:title

From there, jekyll will create destination files of the form /:year/:month/:title.html, but will create links without the file extension. Similarly, you can specify a permalink in the front matter of an individual post or page and the same logic will be applied.

For pagination links, you can also specify a paginate_page setting without a trailing slash:

paginate_path: /page/:num

This will generate pagination destination files of the form /page/:num.html, and will create links without the file extension.

Just make sure you configure your webserver to serve these files appropriately, as noted above.

I've found a handful of other attempts to make this work with Jekyll. Most notably, jekyll#156 and jekyll#2294 either include or link to patches that add something like this to jekyll core. jekyll#219 does something a little similar, but is more targetted at a specific permalink structure. Then there are things like gist:10739376 and this post that approximate something sort of similar using various web server rewrite rules, but do nothing to try and get jekyll to create links with the correct URLs in the first place.

License

This plugin is released under the MIT license, the same as Jekyll itself.