Page 1 of 1

hreflang how to implement?

Posted: Sat Feb 13, 2016 2:16 am
by tamimh
Hi
My new Wordpress website is for US users.
In search console >search traffic> International Targeting I get a message "Your site has no hreflang tags"
searching google, I came across this script http://cbutterworth.com/simple-php-script-adding-hreflang-tag/ from Chris. so I added it to my header.php like this:

Code: Select all

<link rel=”alternate” href=”https://www.mysite.com<?php echo parse_url($_SERVER[‘REQUEST_URI’],PHP_URL_PATH); ?>” hreflang=”en-us” />
I am still getting the "Your site has no hreflang tags" message.
I tested with http://www.technicalseo.info/seo-tools/hreflang/ and I get "Default language tag not existing (en)"

Please drop some advice, my knowledge in scripting is limited.

10x

Re: hreflang how to implement?

Posted: Wed Feb 17, 2016 11:30 am
by Albert Wiersch
Hello,

Regarding the "Default language tag not existing (en)" message, it may refer to no "lang" attribute being used with the "html" element.

For example, try changing this:

Code: Select all

<html>
to this:

Code: Select all

<html lang="en">
Also, to confirm that there is an "hreflang" attribute now (due to your changes), I would view the page in a browser then pull up the HTML source and search for "hreflang" to make sure it's correct and it's where you expected it to be in the HTML source.

I hope this helps!