Change the URL for categories and tags


#1

Hi everyone, I’m migrating my 4000+ blog from Jekyll. Friggen fast, spf13 and team have done an amazing job.

Still wrapping my head around Hugo taxonomies. Is it possible to change the permalink for category and tag archives? Specifically, looking to do this:

root.tld/categories/label -> root.tld/label [sic]
root.tld/tags/label -> root.tld/tag/label

Currently I do this in a post-generate script with a ton of sed. Ironically, this takes longer than Hugo does building the entire site :).

Cheers


#2

Currently no, but it’s a good idea and It shouldn’t be too hard to fix. Could you add a GitHub issue?


#3

I’d like the same thing but I’m not sure if work has been done on that matter. If I should open an issue on GitHub, let me know !


#4

Please open an issue at GitHub.


#5

Curious: What is the build time diff between Hugo and Jekyll (excluding the magic seds)?


#6

Done ! https://github.com/spf13/hugo/issues/1208


#7

Well, I just got an idea and I feel a little stupid now…

What if you just edit the config file and use only singular ? Like this :

[taxonomies]
    category = "category"
    tag = "tag"

Then, in every file, you use metadata in the same singular form. And now, the URL is singular too…

I don’t see any problem with this approach. But maybe I’m wrong ?


#8

That would solve half the initial problem described, I guess.


#9

Yes, you’re right. My issue is not really accurate, then… So, edited !


#10

(Necro?)Bump.
I’d like the very same thing - do you mid sharing your script? Just so I get the idea – I’m not that good at sed stuff… Or is this possible now native hugo?


#11

Well… as I bumped I feel I should share my personal solution.

For sections i just move the content of the section folder - excluding index.html - to root and replace every occourence of ‘/content/’ with ‘/’
find $folder -type f -print0 | xargs -0 sed -i 's/\/categories\//\//g'

I didn’t change post folder, as I kind of like it now ^^