I’m writing my first multilingual site. I have my language selector working and my menu working.
I’m using a single domain name.
I can’t figure out how to render localized content in index.html. I’m using a custom theme. My index.html file content is very typical. It references several partials for the sections.
I’m very new to multilingual so forgive me for not knowing how to ask the correct question.
I don’t know how to localize content in my theme. Is this what I have to do? Or is there a way for the theme to pull localized partial content from the website?
I’ve found some example sites but can’t find a working one with localized content for index.html.
I’ve spent a day trying to find a working example that shows a simple site that has more than one language and the home page (index.html) shows different content for each language.
Thank you in advance for your assistance, greatly appreciated,
Karl Shifflett
Currently living and serving in Mykolaiv, Ukraine. (for real, I moved here to help during the war)
by filename, the one mentioned already: filename.LANGcode.md
by content directory: /content/ja/ or /content/japanese/ (it doesn’t matter if you use the Lang Code or full name, or anything)
by bypassing default linking (a.k.a. by using translationKey frontmatter). (No matter where your files are located, they’ll be linked together as long as they have the same translationKey.)
You can use translationKey in combination with by filename or by content directory. What will happen is if the content creator forgets to add the translationKey, Hugo will fallback to either by filename or by content directory when checking for translations of the content.
Yes, I’ve read the documentation, many times. I have my pages working in multiple languages. For my pages, I’m using the content directory method, actually, both filename and content directory techniques are very easy to implement.
My question was about the landing page, index.html, and the best way to implement multiple languages.
I can’t find any working examples to look at. Do you have any links to working examples that demonstrate having the landing page content localized?
As you know, landing pages are usually complex with several partial templates being used to create the content.
This is one of my Hugo sites I designed and wrote my own theme for and hand-coded:
This afternoon, I’m going to try the technique that @baker sent me.
Thank you very much. We have been getting hit with russian attacks since I wrote you. Been a crazy 10 days. I started working on this last night. Will be working again tomorrow.
Thank you very much for the update, greatly appreciated!! Blessings, Karl