Custom category permalink?

Hi everyone,

I’m currently trying to host a blog using GitHub Pages and I’ve uploaded it to my GitHub page, but I have an issue that requires assistance.

My problem lies in the article category section. I have categories such as:

social and culture
history and culture

and so on. For example:

https://antnb.github.io/categories/social and culture

https://antnb.github.io/categories/history and culture

All these categories result in an HTTP status 404.

It seems that Hugo automatically creates permalink URLs based on the categories we have created, and in my case, there are spaces.

My questions are:

1.How can I solve this issue?

  1. Can I change the permalink for these categories? For example, change https://antnb.github.io/categories/social and culture to https://antnb.github.io/categories/social

blog on github pages are :

Anton Nb

Thank you.

With this front matter:

+++
title = 'Post 1'
date = 2023-01-01T00:00:00-00:00
draft = false
categories = ['social and culture']
+++

Hugo publishes the term page to:

public/categories/social-and-culture/index.html

To publish the term page to…

public/categories/social/index.html

… you need to create a content page for the term:

hugo new content content/categories/social-and-culture/_index.md

… and set the url parameter in front matter:

+++
title = 'Social and culture'
date = 2024-06-17T07:11:13-07:00
draft = false
url = 'categories/social'
+++
3 Likes

allright @jmooring thank you for your help

the same logic also can be implemented on tags correct?

Yes, it can.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.