It's been done for a while now, but I finally got time to showcase it: unionknopf.pl
The most specific feature of this website that I'd like to highlight is true multilanguage support on the frontside.
Despite what's written in documentation, AM doesn't feature (yet) a proper multilanguage support. There are some instructions in the manual that try to work around that limitation by using multiple fields and query strings, but those methods have their own issues - multiple fields complicate templating, editing and maintenance, while query strings for language selection and display make the content unreachable for search engines, therefore are SEO unfriendly. That's why I decided to develop my own solution.
How does it work?
The first sublevel of pages consists of language directories. Each language has its own directory with pages only in this language. For instnace:
Corelation between same pages in different languages is achieved by having a field called LangUniqueID - different language versions of the same logical page need to have the same LangUniqueID, this way they all can be enumerated while each of them is free to have its own URL. This mechanism allows to easily build a language selector and also ensures that proper
<link rel="alternate" hreflang="lang_code" href="url_of_page" />
language tags in header are generated, which hints searchbots about the page being multilanguage, what language version of this particular page is and on which URLs reside other language versions of this page.
Choosing the right language for a visitor
There are many tactics and methods to do this, each with their own pros and cons. I went with visitor's browser preference. The template of the topmost page consists only of code that tries to redirect the visitor to the most fitting language version based on user preference and what's available on the website. If nothing fits, then the default language version is loaded; which by the way is the topmost second level page by order.
Initially I wanted to share the code that made it all possible, but after careful consideration I decided not to do so, at least not yet. My reasoning behind this decision is as follows:
- at the time of making this website most of the code was pretty much experimental and a proof-of-concept. Some of it is packaged, but a lot is raw PHP, which actually already broke once, so it needs to mature. I don't want to be held responsible if it backfires in someone else's project;
- there are many approaches and concepts to multilanguage and multiregion websites, mine covers only one, what works for me, doesn't have to work for someone else;
- finally, probably there would be many people just copy-pasting the code without trying to understand it (or even having the necessary skills to do so) and then having grievances that something's not working as expected or even at all.
Anyway, it all would not be possible without Automad, so thank you, Mad 😃👍.