hreflang how to implement?

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

hreflang how to implement?

Post by tamimh » Sat Feb 13, 2016 2:16 am

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

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

Re: hreflang how to implement?

Post by Albert Wiersch » Wed Feb 17, 2016 11:30 am

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!
Image
Albert Wiersch

Post Reply