0

I have a landing page that supports both English and Spanish. The dir is currently setup as so:

Folder
- index.html
- index-spanish.html
- other stuff

Each html file includes:
<link rel="alternate" href="https://www.example.com/" hreflang="en-def" />

<link rel="alternate" href="https://www.example.com/index-spanish.html" hreflang="es-def" />

From my understanding of hreflang, my Spanish html page should be served to the user if they have their language preference in their browser set to Spanish or by their IP (please correct me if I'm wrong).

The problem is, that isn't happening. So the question is, how can I get this setup to work and serve the correct page? Thanks in advance for all your help!

-Alec

  • I don't think `es-def` is a valid hreflang value. Each value appears to require being 2 characters, so `def` isn't valid. w3schools has a list of valid values [here](http://www.w3schools.com/tags/ref_language_codes.asp) (can't find this anywhere else). – Drew Kennedy Aug 04 '16 at 22:14
  • Thanks for the reply! I tried just es and en, but unfortunately nothing changed. – adilanchian Aug 04 '16 at 22:22

2 Answers2

0

es-def is wrong. Just use es. And you can't expect immediate results. You'll have to wait for Google to crawl your updated page.

tinkerr
  • 975
  • 2
  • 14
  • 32
  • Thanks for the reply tinkerr. So two questions for you then. Do you know how long that would take for google to crawl the page? Also, do I need to reference both `en` and `es` hreflang tags in BOTH html docs? Thanks again! – adilanchian Aug 05 '16 at 04:41
  • Yes, all pages in the Hreflang cluster should be listed on each page of the cluster. How long Google takes to crawl is anyone's guess. – tinkerr Aug 19 '16 at 14:41
0

Issue was resolved! After doing a bit more digging online I found that I can include a .htaccess file that will redirect to the proper webpage based on language settings. For anyone who is looking this is the content of the file:
RewriteEngine on RewriteCond %{HTTP:Accept-Language} (es) [NC] RewriteRule .* http://www.example.com/index-spanish.html [R,L]

Thanks for everyones input!

  • Automatic redirects are not a great idea because there are many ways to screw it up. If you auto-redirect all your bots then they won't be able to crawl all language versions. The bot might keep getting redirected to only the English version. If you really want to redirect, use x-default. Here's my blog post on this https://hreflang.org/redirection-and-international-seo/ – tinkerr Aug 19 '16 at 14:44