Pretty URLs

I was wondering if it’s possible to “prettify” post URLs. For example, I’d like to have my post at https://balance.wtf/bloom instead of https://balance.wtf/2021/03/23/bloom.html. Wonder if this is possible to set in config.json ?

3 Likes

I don’t believe there is.

Is there a specific reason you need these or just personal preference?

Untested, but you may be able to modify Permalinks via config.json in your theme. The default is something like:

{
   "permalinks": {
      "/": "/:year/:month/:filename/"
   }
}

You could try something like:

{
   "permalinks": {
      "/": "/:filename/"
   }
}
1 Like

What @Moondeer posted will work. You can also set "uglyURL":false to remove the .html part.

3 Likes

Unfortunately there are a couple places in Micro.blog that assume the URL format is the default “.html” one that Micro.blog uses, so I don’t recommend customizing the Hugo config file. It will probably mostly work but may cause problems here and there. Use at your own risk! :slightly_smiling_face:

I’d love to add a default setting for this so that it’s easy to change, though.

3 Likes

@manton If I’m understanding right, you’re saying that the .html portion should be left in, but we can still customize the rest of the URL. If that’s the case, is there a way to add metadata to a post to force a specific slug name?

I see @Moondeer gave an example with the filename, but if posting from something like Ulysses you wouldn’t have access to the filename directly. And sometimes you might want the slug to be different from the title, say if it’s really long. Being able to customize the slug would also allow naming of even title-less micro posts as far as the permalink URL goes.

I have pressed manton on front matter access before. It believe it is currently not architecturally accessible but that he is aware of our interest.

Side note: I did manage to stumble upon how to create front matter for category list pages. You can do so by way of theme customization with files such as content/categories/my-category/_index.md

An example: content/categories/critters/_index.md

---
title: "Critters"
description: "All things critter-related."
aliases: [/critters/]
---

a time when date in url can be improved is when it preserves the original draft date rather than publish date