hreflang how to implement?

Discussion about HTML and XHTML related issues.
Post Reply
Rank 0 - Newcomer
Rank 0 - Newcomer
Posts: 1
Joined: Sat Feb 13, 2016 2:12 am

hreflang how to implement?

Post by tamimh »

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 from Chris. so I added it to my header.php like this:

Code: Select all

<link rel=”alternate” href=”<?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 and I get "Default language tag not existing (en)"

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

User avatar
Albert Wiersch
Site Admin
Site Admin
Posts: 3611
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX

Re: hreflang how to implement?

Post by Albert Wiersch »


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

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!
Post Reply