Wrong meta on language subpages

Hi guys,

I have a problem regarding the multilanguage feature. I’m using subpage routes to access different language versions of my website (e.g. mywebsite.com/en, mywebsite.com/de). It all works fine in case of browsing through the different sites, but when I try to search the page via Google the correct site title and meta is only shown for the url of “mywebsite.com/”. When I look at the results, the links to “mywebsite.com/en” or “mywebsite.com/de” (which also point to home) have wrong meta. It doesn’t even show the correct page title, just the first few words of the landingpage’s content. The description is also a generated summary of the content instead of the templates meta description.

Is this a problem with Grav’s multilanguage feature or am I just missing something in my templates? I’m using the standard meta head from “devtools new-theme pure blank” configured through the admin panel. Thanks for your answers!

No ideas for this problem? Thanks for help!

I am also interested in this topic and was hoping for an answer, but as there doesn’t seem to be any input, I am wondering whether it is possible to add the meta description to the languages/lang-code.yaml file perhaps? Have you tried that?

The regular metadata.html.twig file that comes in antimatter theme for example, uses a mix of metadata from site.yaml (not language specific), as well as metadata from pages (language-specific). What you are probalby seeing is the generic site.yaml data.

You can easily adjust that and modify the site.yaml to have some specific lang strings like:

en:
  title: My Title in English
fr:
  title: My Title in French

Then modify the metadata twig so that instead of simply looking up config.site.title it looks up:

{% set site_translated = attribute(config.site, grav.language.getActive) %}
{{ site_translated.title }}

Something like that

2 Likes