I want my website to become eligible for Google+ Direct Connect.
So after googling a bit I found this Google Support page, which has since been edited.
View Google Support page providing these instructions via WayBack Machine:
You can directly link your website by inserting a small snippet of code on your website and then listing that website as your Google+ page's primary link in the About section of the profile. For example, if your Google+ page’s primary link is set to www.pagewebsite.com, you can create a bidrectional link by placing the following code snippet in the
<head>
tag of the site’s HTML:
<a href="https://plus.google.com/{+PageId}" rel="publisher" />
What gives? An anchor tag within the head?
I thought only title/meta/link tags are allowed in the head.
Is it legal to place that above snippet in the head tag?
I think there's an error in Google's documentation and this should be a <link>
-tag, like this:
<link href="https://plus.google.com/{+PageId}" rel="publisher" />
You can test it on https://developers.google.com/structured-data/testing-tool/ if it works. Include the <link>
-tag into your website and see what Google detects with this tool. There's a section "Publisher" where you can see if Google detects the correct information.
I'm using <link>
on my sites and Google detects the correct values.
An a
element inside head
is of course invalid according to any HTML specification. I have no idea why Google tells you to do so, but presumably their software actually looks for such tags.
What happens in practice in browsers is that the a
tag implicitly closes the head
element (you can see this if you look at the document tree in Developer Tools in a browser). This isn’t as bad as it sounds, since the rest of elements meant to be in the head
will still be processed normally. For example, even a title
element works when placed inside body
. To tell truth, the division of a document into head
and body
is just a formality.
The tag <a href="https://plus.google.com/{+PageId}" rel="publisher" />
will be taken as a start tag only, potentially causing naughty surprises, since the start of the document will then be inside a link (which might extend to the end of the document!). Only if the page were served with an XML content type would the tag be taken as “self-closing”. So if you have been forced into using such an element, at least write it with a real end tag;
<a href="https://plus.google.com/{+PageId}" rel="publisher"></a>
It will still be bad for accessibility and usability, since empty links may still participate in tabbing order etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With