1. Wiedza
  2. Pojęcia
  3. Hreflang (hreflang)

Artykuł główny · pojęcie · Pojęcia · Pozostałe

Hreflang (hreflang)

także: hreflang · wersje językowe strony · alternate hreflang

Znacznik informujący Google o wersjach językowych i regionalnych tej samej strony pod różnymi adresami.

Grawerunek symboliczny hasła wiedzy AION

Rozszerzona definicja

Hreflang to znacznik, który mówi Google, że dana strona ma wersje językowe lub regionalne pod innymi adresami. Dzięki niemu wyszukiwarka może pokazać użytkownikowi wersję w jego języku, a nie przypadkową1.

Hreflang nie służy do wykrywania języka — Google robi to algorytmicznie i nie używa do tego ani hreflang, ani atrybutu `lang`2.

Jak to działa

Są trzy równoważne metody: znaczniki `<link rel="alternate" hreflang>` w `<head>`, nagłówek HTTP `Link` oraz wpisy w sitemapie. Google traktuje je jednakowo — nie ma sensu wdrażać wszystkich naraz3.

Każda wersja musi wskazywać siebie i wszystkie pozostałe4, a jeśli dwie strony nie wskazują się nawzajem, znaczniki są ignorowane5. Adresy muszą być pełne, z protokołem (http lub https)6.

Dlaczego to ważne

Bez hreflang Google może pokazać Polakowi wersję angielską. Wersje językowe są uznawane za duplikaty tylko wtedy, gdy główna treść strony pozostała nieprzetłumaczona7 — ale przy niepełnych adresach i braku linków zwrotnych i tak tracisz kontrolę nad tym, którą wersję zobaczy użytkownik.

Częste błędy i mity

  • Brak linków zwrotnych — najczęstszy błąd; bez nich znaczniki są ignorowane5.
  • Kod regionu bez języka (np. `be`) — nieprawidłowy; pierwszy człon to zawsze język8.
  • Kody typu `EU`, `UN`, `UK` — Google ich nie obsługuje w hreflang9.
  • Brak `x-default` dla użytkowników, których język nie pasuje do żadnej wersji10.

Źródła i odwołania

  1. Tell Google about localized versions of your page

    developers.google.com ·

    If you have multiple versions of a page for different languages or regions, tell Google about these different variations. Doing so will help Google Search point users to the most appropriate version of your page by language or region.
  2. Tell Google about localized versions of your page

    developers.google.com ·

    Google doesn't use hreflang or the HTML lang attribute to detect the language of a page; instead, we use algorithms to determine the language.
  3. Tell Google about localized versions of your page

    developers.google.com ·

    The three methods are equivalent from Google's perspective and you can choose the method that's the most convenient for your site.
  4. Tell Google about localized versions of your page

    developers.google.com ·

    Each language version must list itself as well as all other language versions.
  5. Tell Google about localized versions of your page

    developers.google.com ·

    If two pages don't both point to each other, the tags will be ignored.
  6. Tell Google about localized versions of your page

    developers.google.com ·

    Alternate URLs must be fully-qualified, including the transport method (http/https)
  7. Tell Google about localized versions of your page

    developers.google.com ·

    Localized versions of a page are only considered duplicates if the main content of the page remains untranslated.
  8. Tell Google about localized versions of your page

    developers.google.com ·

    You can't specify the country code by itself. The first code stands for the language and Google doesn't automatically derive the language from a country code.
  9. Tell Google about localized versions of your page

    developers.google.com ·

    If you use codes that are listed as reserved for something else, Google Search ignores that part of the annotation (for example, using EU, UN, or UK in hreflang annotations doesn't have an effect on Google Search).
  10. Tell Google about localized versions of your page

    developers.google.com ·

    The reserved x-default value is used when no other language/region matches the user's browser setting.

Każde zdanie powyżej odsyła do dosłownego cytatu ze źródła. Daty to daty publikacji lub pobrania źródła.

Źródła faktów

  • Hreflang wskazuje Google wersje językowe i regionalne strony. — web
  • web