How to make canonical URLs pretty in jekyll

Jekyll is a great static site generator, with a great ecosystem of plugins to create almost all you need. But since every plugin is handling things a wee bit different, sometimes the results are not consistent throughout the page.

Since we always want to render nice canonical URLs with no unnecessary index.html files, I figured having a nice liquid plugin is the best choice, since the current Jekyll pagination plugin is always putting an index.html at the end with no (apparent) way to strip it away.

But since there are plugins for almost every usecase, I found this nice liquid filter plugin for beautifying URLs. Simply copy that code into the _plugins dir and use it like this:

<meta
  property="og:url"
  content="http://webgeist.dev/kb/2019-01-20-jekyll-beautify-urls/"
/>