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 ?
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/"
}
}
What @Moondeer posted will work. You can also set "uglyURL":false
to remove the .html
part.
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!
I’d love to add a default setting for this so that it’s easy to change, though.
@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
Just want to add a +1 for the ability to customize the URLs a bit. The things I can think of:
- Including or excluding the date lead in
- Allowing the URL to be the full post title (to some large limit) rather than a truncated version (I think this used to matter for Google ranking, but I don’t know if that’s still the case)
-
.html
or not - Maybe even dashes vs underscores
The first two are the main ones I’m interested in.
Thanks, I’d like to revisit this. What I had posted earlier is still the case, unfortunately, that there are some assumptions in Micro.blog that need to be updated. But when that happens, some of this customization could probably happen with a plug-in.
I’d also like to see the html get dropped in addition to the first two. I’ve always felt it’s redundant having that in the URL, ignoring the visual aspect.
A big +1 for the first two from @bjhess’s list. I like the URLs to be clean. They are easier to share that way. And especially for long-form posts, simpler to remember too. Control on the permalink pattern and slug/url for posts would be a helpful addition.
Yes, it’s a bit sad, since Hugo supports pretty URL by default.
Also, it’d be helpful if we were able to adjust the suggested slug. For one, it only works with English. I’m happy to write them manually for one of my blogs.
Adding another +1 here
My reasoning is I feel content is less timeless when the date of publication is right in the URL. I also update posts, and that’s not reflected by the single date. Lastly it’s just nicer when sharing URLs if they’re short and readable.
As for how this could work, I think the current behavior is a fine default. For us picky people, a single slug text field on the new post screen, much like Wordpress does, would be enough. It should check to make sure another post isn’t already using the specified url, and if it’s good the post would use it for permalinks and urls everywhere they appear.
Whilst people are waiting for this change, there is a workaround that can be used: Redirects.
- Go to the web app →
- Select the Pages tab →
- Select the
New Redirect
button → - Use the first box for the simple URL you’d like to use →
- Use the second box for the actual URL →
- Select the
Add Redirect
button.
An example: today-i-learned.net/next
I’m not really bothered by dates in URLs but I mainly write in Gaelic and a custom slug field on the new / edit post screen as mentioned by @nominal would help me with a number of other issues I have with URLs generated by Micro.blog.
It could also help with localization if the default pages /archive, /photos, / about and /replies could be given custom slugs.
Is this still the case? I’d love to get rid of the .html
extension in my urls.
Thanks!
It’s still the case. Still something we want to provide an option for.
Even if the dates have to stay (considering the nature of micro posts I understand why), being able to drop the extension and have slug control will be the last holdout Micro.blog features for me. Everything else is gravy.
Throwing my desire in here as well for more control over URLs. I’d love to be able to define the path a little better, i.e. /blog/2023/11/my-custom-slug
, and to drop the .html
. Looking forward to a solution whenever it’s ready!