Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change URL path #1011

Open
jamesdeluk opened this issue Nov 3, 2024 · 8 comments
Open

Change URL path #1011

jamesdeluk opened this issue Nov 3, 2024 · 8 comments

Comments

@jamesdeluk
Copy link

jamesdeluk commented Nov 3, 2024

Is it possible to change the URL?

For example, currently it is:

www.mywebsite.com/posts/category/sub-category/my-post

Is it possible to drop the categories and make it simply:

www.mywebsite.com/posts/my-post

?

Failing that, can I set up redirects? It would be a lot more complicated but it's better than nothing.

Thanks!

@jackwu925
Copy link

I have the same issue with you dude. The URL is a bit long and complex. :-(

@jamesdeluk
Copy link
Author

jamesdeluk commented Nov 4, 2024

Oh, that was simpler than I thought. It's a Hugo thing, not a theme thing.

To config.yaml, add:

permalinks:
  page:
    /: ':section/:slugorfilename'

More detail: https://gohugo.io/content-management/urls/#permalinks

I suggest adding it to the template.

Interestingly, the long URL (with cats/sub-cats) still seems to work too.

@jackwu925
Copy link

thx that makes more sense. I will try that.

@jamesdeluk
Copy link
Author

OK, looks like it doesn't work. It seemed to... But now it doesn't. Did you have any luck with it?

@jackwu925
Copy link

Sorry, still not yet, and I have no idea :-(

@jamesdeluk
Copy link
Author

I think I was on the right path before. The solution looks to be:

permalinks:
  page:
    posts: ':slugorfilename'

(note the addition of posts that I forgot last time)

I've gone straight for slugorfilename, i.e. www.website.com/this-is-a-post

Does this work for you?

@jackwu925
Copy link

: ( It still doesn't seem to work for me. Baddddd....

@jackwu925
Copy link

Anyway, I plan to put it aside temporarily. It took me so much time. 👎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants