jhvanderschee / hugobricks

MIT License
74 stars 26 forks source link

Best practices and/or enhanced support for i18n site #55

Open expersso opened 8 months ago

expersso commented 8 months ago

Loving this theme!

I'm trying to add i18n support, but I'm wondering about the best practice for url management. For example, let's say I implement a language switcher in the navbar like this:

<div>
        <ul class="language-list">
            {{ range $.Site.Home.AllTranslations }}
            <li><a href="{{ .Permalink }}">{{ .Language.LanguageName }}</a></li>
            {{ end }}
        </ul>
</div>

This works, but it sends the user to the landing page, whereas I would prefer for it to link to e.g. /nl/about if you click on it while on the about page.

More importantly, I wonder about how to deal with the navbar links defined in data/en/header.yaml. Do I need to change the urls on all these manually for alternative languages, e.g.

menuitems:
  - title: About Us in Dutch
    link: nl/about/
  - title: Contact us in Dutch
    link: nl/contact/

Or is there already support for automating this?

Lastly, could one add sitemap functionality that treats the main language as the canonical reference and lists alternative languages?

Atamantra commented 8 months ago

Hello, I also use this and love this theme and I am also wondering about this topic. what I did was I added a language link at the header.yaml and whenever someone wants to change the language It goes back to the homepage of that language. This way it would be much more accessible but I guess much more mapping-crosslinking is needed 🫨

AlbertusMagnus7 commented 7 months ago

I love the theme, it's beautiful, great work!

However, as someone who does not often deal with Hugo and the likes, I am having a hard time to get a simple language switcher in the header menu to work. I like how Hugoplate does it, but I can't manage to port that solution over easily.

What's the best practice to allow the user to switch languages on site?

omartek commented 4 months ago

I'm interested too.

thanks

jhvanderschee commented 2 days ago

Although it is not too hard to fix this I am wondering: you expect somebody to land on a specific page in the wrong language? I mean... isn't that 90% from Google and therefore in the right language? Anyway... it is perfectly possible to implement this, BUT you need a proper administration of all alternative URL's. It is not easy to maintain, as the current language switcher is a piece of cake.

I will leave this open as I might fix this later.