Allowing quotes in Hugo generated slugs

A necessary feature to migrate your blog to a new platform.

As mentioned before, I took the decision to move my blog from Orchard CMS to Hugo. I’m quite often very precise in my work, while paying attention to useless costs or needless time-wasting for paid work, sometimes “good enough” is all you should go for). I’m currently going through every single post from the past, e.g. to provide alt text to images or to update italic class names in text to inline code fragments in markdown to let these come out more in the text and align with today’s standards set by StackOverflow and others. Is it necessary? No, but it improves accessibility and it gives me satisfaction of having clean blog posts. And since I’m doing this while watching some light tv shows it even feels like time better spent than just watching tv (one could discuss the value when doing this instead of learning, work or family time).

What’s more important in the migration process than finetuning the layout, is maintaining your blog post URLs. Cross-linking from your own posts is something you can easily fix, but you don’t have control over incoming links from the wide web. Orchard CMS converted blog titles to URL slugs, including encoding special characters when necessary. This resulted in post URLs like https://www.bartlannoeye.com/blog/keep-an-eye-on-your-app’s-api. Hugo on the other hand allows you to define your URL slug in FrontMatter, so no matter how you organize your posts on the platform, you can easily keep the URLs in the format you want.

---
title: Keep an eye on your app's API
slug: keep-an-eye-on-your-app's-api
---

Except for special characters … which will get trimmed. Above slug gets converted to keep-an-eye-on-your-apps-api. Luckily there’s a fix for this by adding an alias with your old URL. This will redirect to the new one without special characters, but more importantly: your link keeps on existing instead of returning a 404.

---
title: Keep an eye on your app's API
slug: keep-an-eye-on-your-apps-api
aliases:
    - /blog/keep-an-eye-on-your-app's-api
---
Licensed under CC BY-NC-SA 4.0; code samples licensed under MIT.
comments powered by Disqus
Built with Hugo - Based on Theme Stack designed by Jimmy