For sorting purposes, I structure my posts using only bundles, even if there’s only a single markdown file with no other assets:
posts/2021-08-17-my-first-post/index.md
I set it up this way so that when I’m looking at my posts in VS Code, they are sorted from oldest → newest post, as opposed to being sorted alphabetically which I don’t want.
When I view this post in my browser, the URL is:
domain.com/posts/2021-08-17-my-first-post
However, I want it to look like this (minus the date in the directory name):
domain.com/posts/my-first-post
How would I go about making the URL of every post ignore a date prefix like that, if it’s there? I’m hoping for a “generic” solution that doesn’t involve adding front matter to every page.
Thanks for the link. I did see that but honestly there’s a lot of information there and I wasn’t sure what I should do. For example, what I need to do involves splitting a string, substring with regex, or some other type of operation. The examples there show using existing variables to build a URL. I don’t see a more complicated example which I think is what I need.
I’m also not sure what a “slug” is. I see :sections but I’m not sure what that means. I assume it means parts of the URL. So /posts/mypost would be two sections?
I also have no experience with golang so if there’s a simple mechanism to strip the string like I need, I won’t know about it.
I get what looks correct. The issue is that if I change the title of the post, it will break the URL. So I don’t want that. I’d rather it take the name of the folder (which I won’t change). So I’d like to do something like this (rough example):
and set slug in frontmatter
OR
try to set url in frontmatter
url
the full path to the content from the web root. It makes no assumptions about the path of the content file. It also ignores any language prefixes of the multilingual feature.
I already did this for the title (to remove the date prefix). This would allow me to rename the title and keep the slug as it was before to control the URL. I didn’t want to add yet another property to my archetype frontmatter but I guess it’s a small price to pay. I appreciate the tip.