Forum Moderators: Robert Charlton & goodroi

Message Too Old, No Replies

hreflang tabs pointing to pages that don't exist

         

JinKazama

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

10+ Year Member



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?

phranque

3:10 pm on Nov 18, 2014 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



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]

seoskunk

12:14 am on Nov 19, 2014 (gmt 0)

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



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

JD_Toims

12:35 am on Nov 19, 2014 (gmt 0)

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



<?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...]

seoskunk

12:44 am on Nov 19, 2014 (gmt 0)

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



Yeah that's better JD thanks

JinKazama

2:52 pm on Dec 2, 2014 (gmt 0)

10+ Year Member



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.