Welcome to WebmasterWorld Guest from 18.206.48.142

Forum Moderators: Robert Charlton & goodroi

Message Too Old, No Replies

hreflang tabs pointing to pages that don't exist

     
1:18 pm on Nov 18, 2014 (gmt 0)

New User

5+ Year Member

joined:July 16, 2014
posts: 4
votes: 0


A site I work with have recently taken a clone of their .com site to create a Australian version with a .com.au domain.

They're adding in hreflang code to every page on both sites automatically, referencing the site itself, along with the alternative version of that page on the alternative domain.

The trouble is, not every page on the UK site exists on the Aus site, and vice versa.

So they would end up with a page on the UK site containing an href tag to itself, and an href tag to a page on the Australian site that does not exist.

I've advised that they should be editing this so that any page without an alternative on another domain does not contain the hreflang tag, but they are reluctant and want to know how much impact it would have to leave this code on every page.

Does anyone have any examples of implementing the tags in this way, or suggestions of what the impact might be?
3:10 pm on Nov 18, 2014 (gmt 0)

Administrator

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
posts:11820
votes: 236


welcome to WebmasterWorld, JinKazama!


for what it's worth, Google suggests broken links are an indicator of low technical quality in Webmaster Guidelines - Webmaster Tools Help:
http://support.google.com/webmasters/answer/35769?hl=en [support.google.com]
12:14 am on Nov 19, 2014 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member Top Contributors Of The Month

joined:Sept 14, 2011
posts:1045
votes: 132


Surely it depands how you do this, simply insert this code in your head and you won't have any isssues (vary code for .com.au)

<?php $url = '' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; ?>
<link rel="alternate" href="http://<?php echo $url; ?>" hreflang="en-gb" />

Then add a rule in your cms that says .com.au YES/NO and add the oz code or not
12:35 am on Nov 19, 2014 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member Top Contributors Of The Month

joined:July 19, 2013
posts:1097
votes: 0


<?php $url = '' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; ?>
<link rel="alternate" href="http://<?php echo $url; ?>" hreflang="en-gb" />

Not sure I understand your post completely, but I'd go with:

<?php $url = 'canonical.domain.ext' . $_SERVER['REQUEST_URI']; ?>

Rather than:

<?php $url = '' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; ?>

The reason is $_SERVER['SERVER_NAME'] and $_SERVER['HTTP_HOST'] can both potentially cause issues for canonicalization and $_SERVER['SERVER_NAME'] could cause issues if a script is running on a virtual host since the virtual host will be returned rather than the canonical.domain.ext of the site.

[php.net...]
12:44 am on Nov 19, 2014 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member Top Contributors Of The Month

joined:Sept 14, 2011
posts:1045
votes: 132


Yeah that's better JD thanks
2:52 pm on Dec 2, 2014 (gmt 0)

New User

5+ Year Member

joined:July 16, 2014
posts: 4
votes: 0


Thanks for the help guys.

It was more about the implications of having an hreflang tag pointing to an alternate that does not actually exist that I was interested in. Assuming they will be seen as 404s so will work on avoiding this.
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members