HUGO

Translating Section Names

Hello,

I can’t find any examples anywhere, so I thought here would be the place to ask.

I have a Section on my site called “Music”, where each bit of content is an album or a release. I also have my site translated into Portuguese. My URL’s typically end up like:

  • baseurl/en/music/album-name-in-english
  • baseurl/pt/music/album-name-in-portuguese

I was wondering if it was supported to translate the section name, in this case “music”? In Portuguese this would be “musica”. So I’d like to end up with:

  • baseurl/en/music/album-name-in-english
  • baseurl/pt/musica/album-name-in-portuguese

I typically have a content folder that looks like this, with each bit of content sharing a “translationKey”.

  • content/music/album-name-in-english.md
  • content/music/album-name-in-english.pt.md

I’ve seen examples of people translating “About” pages and changing the slug, but they don’t tend to sit inside Sections.
Thanks for any help!

is this an help?

don’t know if this works :wink:

[languages]
  [languages.en]
    [permalinks]
      music = "/music/:year/:month/:day/:title"
  [languages.pt]
    [permalinks]
      music = "/musica/:title"

After changing [permalinks] to [languages.pt.permalinks], all the content pages changed their URLs, but the list page (/musica/) is blank.

However, I think I have a solution - but I’d appreciate someone letting me know if this is sane or not:

I’ve restructured my content as such:

  • content/english/music/album-name-in-english
  • content/portuguese/musica/album-name-in-portugusse

I’ve added a translationKey = “music” to _index.md inside “music” and “musica”. I’ve also ensured the translationKey inside the actual album content is also the same (ie, “album-name”). This appears to work, but perhaps I’m missing a downside to this?

1 Like