0

I have a Drupal 7 setup with an internationalized site. The default languages is English but the content is also available in German. However the site focuses on a German audience. As in Drupal you cannot switch the default languages without messing up all string translations, we have a custom language negotiation rule implemented (hook_language_negotiation_info()) that makes sure if no session or query parameter (like lang=en) is set, the site is shown in German. So, to make it short: If an user accesses our site like this:

http://www.example.com

it will be shown in German. Nevertheless Facebooks open graph scraper scraps the site always in English, as it would add programmatically lang=en to all URLs. How can that be? we have the following language specific meta tags:

<link href="https://www.example.com/node/581?lang=en" rel="alternate" hreflang="en" />
<link href="https://www.example.com/task/581" rel="alternate" hreflang="de" />
<meta property="og:locale" content="de_DE" />
<meta property="og:locale:alternate" content="en_US" />

Does anybody know, what I could do, to convince Facebook open graph scraper to scrape the German version as default?

  • are you using metatag module? – oksana-c Feb 22 '16 at 0:01
  • @oksana-c Yes, metatag module is installed. – user5950 Feb 22 '16 at 22:24
  • do your other tags (like description and so on) show up in German on the page where you copied your tags from? – oksana-c Feb 22 '16 at 22:43
  • @oksana-c Yes, the other tags show up in German. – user5950 Feb 23 '16 at 13:32
1

Without knowing exactly how the following tags are generated I cannot provide the exact solution to your issue, but only to point out what causes the Facebook to grab EN version.

1. <link href="https://www.example.com/node/581?lang=en" rel="alternate"
> hreflang="en" />

2. <link href="https://www.example.com/task/581"
> rel="alternate" hreflang="de" />

Tags 1 & 2 have rel attribute set to alternative, which tells facebook that both links from tag 1 & 2 can be used for fetching info. Therefore it grabs the first one in line.

Each page should have rel="canonical" tag that will tell facebook and all other crawlers, that it is a primary url for that page that should be used for fetching info.

I do not know if you have a link tag with rel="canonical" in your source code, as you only copied a portion of your meta tags. I suggest you check if it is present, and what page version it points to. If it is not present, add it.

Also, meta tag og:url should point to the right version of the page.

<meta property="og:url" content="https://www.example.com/task/581" />

Test your tags by fetching new meta info via Facebook Open Graph Debugger.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.