1

According to Google, you can specify languages in a sitemap like this:

<url>
<loc>http://www.example.com/english/page.html</loc>
<xhtml:link 
           rel="alternate"
           hreflang="de"
           href="http://www.example.com/deutsch/page.html"/>
<xhtml:link 
           rel="alternate"
           hreflang="en"
           href="http://www.example.com/english/page.html"/>
</url>

However, I just need to specify that ALL the sitemap/website is in Spanish, which means it's not a multi-language sitemap, it's a one-language sitemap but that language happens to be "Spanish".

Should I include a hreflang tag for each and every URL? or is there a better way to do this, like specifying it in the header section?

John Conde
  • 217,595
  • 99
  • 455
  • 496
Sergio
  • 658
  • 1
  • 9
  • 22
  • XML is a specific sitemap language, https://www.woorank.com/en/edu/seo-guides/xml-sitemaps – Umesh Jul 04 '20 at 02:02

1 Answers1

0

No, setting header for the sitemap xml only sets it for the sitemap.xml and not all locations declared in the sitemap. You have to declare it for all locations.

Checked with the URL inspection tool to see if there are any errors with Google trying to index your site.

If you had access to the server, you can set Link response header alongst the following lines.

Nginx

add-header Link <$scheme://$host$request_uri>; rel="alternate"; hreflang="es"

Apache

Header set Link "<%{REQUEST_SCHEME}://%{HTTP_HOST}%{REQUEST_URI}>; rel=\"alternate\"; hreflang=\"es\""

Also, you could set the "lang" attribute on the "html" tag or "link" tag of every page in your website. You can use a template for this if your site is built using a static site generator.

If you only have access in Cloud console, you have to make an entry for every location in your website in the sitemap.xml.

Oluwafemi Sule
  • 36,144
  • 1
  • 56
  • 81
  • I have full access to the server. So, there's no way to specify language in the header of the sitemap xml file? I'm trying to do this since Google only indexed about 2% of my webpages (there are 50,000) so I thought language not being specified could be a factor on this. – Sergio Jun 27 '20 at 19:24
  • 1
    No, setting header for the sitemap xml only sets it for the sitemap.xml and not all locations declared in the sitemap. You have to declare it for all locations. Have you checked with the URL inspection tool to see if there are any errors with Google trying to index your site https://support.google.com/webmasters/answer/9012289 – Oluwafemi Sule Jun 29 '20 at 18:13
  • OK, that clarifies my question. So, in terms of Google efficency, is it helpful to specify the language/region for every link then? and yes, I've used the search console for URL inspection and there's thousands of links marked as "discovered, not indexed" without mistakes. Could you post your previous comment as an answer so I can mark it as the correct answer? – Sergio Jul 01 '20 at 22:18
  • 1
    Yes, it's helpful to specify language for every link for SEO benefits. – Oluwafemi Sule Jul 02 '20 at 06:45
  • Thanks a lot!! Please post your previous comment as an answer so I can mark it as the "Accepted Answer" (I can't do that for comments) – Sergio Jul 04 '20 at 00:12