With multilingual websites, it is often not only the actual content that is available in different languages. In most cases, the page title, meta description and URL are of course also adapted according to the language. The latter is usually not a problem, as WordPress automatically generates the slug or URL based on the page title.
A unique slug is important – because WordPress relies on the slug of the page that has just been called up when compiling the page content. In other words, WordPress always searches the content from the database according to the slug and therefore the address of the page.
WordPress usually generates this slug automatically from the title of the page, post or category. This makes the URL directly readable, so to speak – instead of a page ID (e.g. “/?page_id=1955 for this page”), a readable address (e.g. “wordpress-multilingual-with-identical-urls-slugs” for this page) is then displayed in the address bar of the browser. This has direct and indirect advantages – also for search engine optimization – because the URL directly reveals something about the content of the requested page.
Multilingual website with identical slugs
However, a problem can arise if you want to use identical URLs or identical slugs on a multilingual website. With identical URLs or identical slugs, WordPress cannot clearly assign which content should be delivered to which page and content may be mixed up. For example, posts in a category are loaded correctly, but the description text for the category and any individually defined page title and meta text (e.g. customized with the SEO tool SEOPress) may be loaded in the other language.
Multilingual category pages with identical addresses
In practice the problem will occur relatively rarely – because, as already mentioned, the slug is usually generated from the page title automatically. If you now operate a multilingual site (e.g. with the help of the WPML plugin), an English page title is translated into a readable URL in the same way as a German page title. However, it may become difficult if you want to use a taxonomy to set up archive pages or directories that have identical titles or designations in both languages. In this case, the slug would also be identical – but WordPress can no longer clearly assign the content. The slug of a category must therefore be unique so that WP can assign the correct content via the slug.
Handle URL and slug separately
An example: we have a multilingual website that is about cities. For a page about “Berlin”, we want the address to be “/berlin” in both languages. However, the following situation arises:
- German content: DE-Domain/berlin
- English content: EN-Domain/berlin-en
or if English is selected as the primary language:
- English content: EN-Domain/berlin
- German content: DE-Domain/berlin-de
We now actually want to separate the URL from the slug – define the URL and slug individually. We still need different slugs for the correct assignment of content, but we want identical URLs on the outside. This can be achieved with the Permalink Manager Pro plugin, for example.
Customize URL with Permalink Manager
Mit Permalink Manager Lite (de.wordpress.org/plugins/permalink-manager/) lassen sich URLs individuell jenseits des Slug-Mechanismus definieren – mit Permalink Manager Pro (permalinkmanager.pro) funktioniert das auch für Kategorien bzw. Taxonomien. Dementsprechend können wir mit Hilfe von Permalink Manager Pro für die englische und die deutsche Version der Kategorie “Berlin” nun dieselbe URL eintragen – in diesem Falle wäre “/berlin” unsere Wunsch-URL, unter der die Kategorie zum Thema “Berlin” in beiden Sprachen erreichbar sein soll.
With Permalink Manager Lite (wordpress.org/plugins/permalink-manager/), URLs can be defined individually beyond the slug mechanism – with Permalink Manager Pro (permalinkmanager.pro), this also works for categories and taxonomies. Accordingly, we can now use Permalink Manager Pro to enter the same URL for the English and German versions of the “Berlin” category – in this case, “/berlin” would be our desired URL under which the category on the topic of “Berlin” should be accessible in both languages.
- Deutsche Inhalte: DE-Domain/berlin
- Englische Inhalte: EN-Domain/berlin
This means that the category is now accessible in both languages at the same address – and WordPress can still assign the multilingual content correctly.