I don’t even really know what hives are, but I know that my content directory structure is already giving me them. I started my content with these long, kitschy titles, trusting in hugo to organize them for me, but finding my way down to these folders tends to look like.
cd content/posts/how-little-do-you-need-to-start-a-hugo-site
Ah, but I hear you saying, “This is what tab-completion is for!” Yes, it sure is, and boy does it make life on the command line a lot easier, but what happens when you have something like this?
cd content/posts/how-<Tab>
how-little-do-you-need-to-start-a-hugo-site/ how-a-little-theming-makes-your-hugo-site-less-painful/ how-to-name-your-blog-posts-in-the-longest-way-possible/ how-did-i-let-this-happen-to-myself/
Should I be more creative in my title names? No. I deserve that freedom. The driving issue here is that in a list of these directories, I don’t know which one is first or when it was written. Sure, the index.md file has the date these were written, but that doesn’t help them line up under the content directory. A ls -la command might help, but then I have to go sifting through a long list. This presents two sub-goals:
- I want these ordered automatically, and
- I don’t want the link names of my posts to be at the mercy of my directory structure.
As it turns out, this is what permalinks are for. According to the docs, these define custom URL patterns for your pages. What does that mean? Well, let’s say I have a content type of posts. If I add the following to my hugo.toml…
# hugo.toml
[permalinks]
posts = '/posts/:year:month:day-:slug/'
And I decide to rename content/posts/how-little-do-you-need-to-start-a-hugo-site/ to content/posts/20260528-build-a-blog/, my url links for the live site will come out looking like https://diggit-metal.com/20260528-how-little-do-you-need-to-start-a-hugo-site. Despite the similarities, my directory does not factor in the naming for the url anymore. The tokens :year, :month, :day, and :slug pull from the front-matter of index.md. This means I can arrange all of my content behind the scenes that works for me, and deliver to you my content in a way that is separate from that.