mozilla / bedrock

Making mozilla.org awesome, one pebble at a time
https://www.mozilla.org
Mozilla Public License 2.0
1.18k stars 919 forks source link

Add hreflang tags to XML Sitemaps and remove them from web pages #15541

Open a-kyne opened 23 hours ago

a-kyne commented 23 hours ago

Description

Our pages will probably load faster if we include Hreflang tags in the XML Sitemaps rather than in HTML, so that hreflangs do not need to be generated when a website URL is requested.


Success Criteria

Example:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
  xmlns:xhtml="http://www.w3.org/1999/xhtml">
<url>
    <loc>https://www.mozilla.org/</loc>
    <xhtml:link
               rel="alternate"
               hreflang="x-default"
               href="https://www.mozilla.org/"/>
    <xhtml:link
               rel="alternate"
               hreflang="en-ca"
               href="https://www.mozilla.org/en-CA/"/>
    <xhtml:link
               rel="alternate"
               hreflang="en-gb"
               href="https://www.mozilla.org/en-GB/"/>  
  </url>
<url>
    <loc>https://www.mozilla.org/en-US/page.html</loc>
    <xhtml:link
               rel="alternate"
               hreflang="en-us"
               href="https://www.mozilla.org/en-US/page.html"/>
    <xhtml:link
               rel="alternate"
               hreflang="en-ca"
               href="https://www.mozilla.org/en-CA/page.html"/>
    <xhtml:link
               rel="alternate"
               hreflang="en-gb"
               href="https://www.mozilla.org/en-GB/page.html"/>
    <xhtml:link
               rel="alternate"
               hreflang="en"
               href="https://www.mozilla.org/en-US/page.html"/>
    <xhtml:link
               rel="alternate"
               hreflang="de-de"
               href="https://www.mozilla.org/de/page.html"/>
    <xhtml:link
               rel="alternate"
               hreflang="de"
               href="https://www.mozilla.org/de/page.html"/>
    <xhtml:link
               rel="alternate"
               hreflang="fr-fr"
               href="https://www.mozilla.org/fr/page.html"/>
    <xhtml:link
               rel="alternate"
               hreflang="fr"
               href="https://www.mozilla.org/fr/page.html"/>
  </url>
</urlset>
janbrasna commented 18 hours ago

FYI this seems to have been described in the past: (…so additional info may be there as well)