By default, Hugo adds some prefixes to the site’s URLs.
example.com/categories/category-name/. Same with tags.
As for posts and categories, it seems unnecessary to me. I would like to have the name of the post/category right after the site domain, with no prefix.
Fortunately, this can be achieved by adding this simple code snippet to the site’s main configuration file:
# Remove the "/posts/", "/categories/", "/tags/" prefixes from URLs. permalinks: posts: '/:filename/' categories: '/:slug/' tags: '/:slug/'
This code snippet will change the URL structure of posts, categories and tags. The URL of posts will be taken from the file name of the post’s
.md file. The URL of categories and tags will be automatically taken from the slug on the taxonomy. For example, The URL of a tag named “Static site” will be “example.com/static-site/”.
You can use other values, besides the file name and slug, like the date for example. Here’s the full list of permalink configuration values.