3

I'm trying to improve SEO on a platform i'm working with, and was advised to add rel="next" and rel="prev" links to my pages to make it clearer to google which URLS are paginated.

My question to you is, does google look anywhere except the head element for them?

Can i add them to the next page buttons themselves? Will that still work?

EG:

<a href='page.php?p=2' rel="next">
<a href='page.php?p=3' rel="next">

Or Maybe can i add them as a link element, but any random place in the page outside the head?
EG:

<link rel="prev" href="page.php?p=2">
<link rel="next" href="page.php?p=3">

Or does that type of link explicitly require it being present in the head and only in the head?

Accoring to Google WebMaster Central it's not required to be outside of the head, but that seems kind of ambiguous to me.

rel=”next” and rel=”prev” only need to be declared within the section, not within the document .

Does anyone happen to know what the specifics of that tag are and whether it'll index it properly if i put the link tags outside the head element?

(for anyone wondering why on earth i don't just put the rel tag in the head, it's because it needs to be dynamic and i couldn't find a way to dynamically insert php into the head element with our platform)

4

The specifics of Rel next and Rel Prev can be found on the google blog here: https://webmasters.googleblog.com/2011/09/pagination-with-relnext-and-relprev.html

The Rel next and rel prev go in the header.

Edit: Php is fully supported on any aspect of an dynamic page. Simply doing something like

<?php echo 'https://yourdomain.com/'.$yourdynamicinfo; ?>

would work perfectly fine in your html head.

It also states that the code must use the

<link rel="next" must be used in the header.  

It is not like a

rel="no follow".

As for indexing properly, if google says it is looking for a specific tag, it is best to follow the guidelines they have in place for a tag. As it won't hurt you SEO wise, it will also not benefit you either. Also please be aware that post was from 2011 so it is quite old.

Ultimately this is to help bots understand the layout of your website and should not affect your rankings overall.

  • Thanks for the explanation, and yes, i know php is fully supported anywhere in a php file, but this is a web platform that uses templating and xml everywhere, there's no "head.php" to edit, or anything like that – Zachary Craig Feb 4 '17 at 17:04
  • @zack6849 i also forgot to mention this tag was originally created for articles that had multiple pages that were broken up and not necessarily for pagination pages, so you may negate the advantages of this tag on pagination. The rel next and rel previous are to help build relevance to pages that are supposed to be posted together. For example if you had a 10,000 word post, you could break it up in chunks and to tell google that article is part of a chain. That would be most beneficial to your seo. What templant framework is it using? If it is a php driven site, there is an include. – DEVPROCB Feb 10 '17 at 4:01
  • We're using magento2, which has includes, but you can't simply throw a php file in there, you have to create a module that magento loads via reflection and requests where you want your code to appear. Are you saying that rel='next' and rel='prev' on something like a list of products wouldn't be good for SEO? – Zachary Craig Feb 10 '17 at 12:04
  • @zack6849 for a templating engine, you would simply find the template file and modify it to your expectations there. As for the SEO side, it is not that it won't be beneficial, I am only stating google or really any major search engine has not dictated that it would be hugely beneficial. Anything that can have a positive effect is worth a try, but I would not expect the page to shoot up to "#1" just because of the use of a specific tag.To many "signals" for one tag to really affect to much in SEO. But when you hit multiple signals, that is when, you will see ranking increase, so it may help – DEVPROCB Aug 24 '17 at 13:53
  • Haha, talk about a necro bump and yes, I know, but the point was with magento 2, there's no "template" for the header, you have xml files that the system uses to build the head element, but they only support adding script or css files, so my point was it wasn't anywhere near as easy with that system, and i agree, i don't think that one tag will make or break our site, but our companies SEO guy requested it specifically and it was the task i was assigned, whether or not it was valuable in my opinion wasn't important, as I'm not an SEO guy, just a developer. – Zachary Craig Aug 24 '17 at 13:56
1

Despite what anyone says or reads, rel is an attribute of <link> and that element is required by the HTML specification to always be in the <head> no matter what Google or anyone else says.

If the rel attribute is used, the element is restricted to the head element.

Anywhere else makes your HTML invalid.

  • The a and area elements can have the rel attribute, too. And the next/prev link types can be used with all three elements (a, area, link). -- It’s also not accurate to say that a link element with a rel attribute must be in the head element, as there are body-ok link types. – unor Feb 4 '17 at 17:57
  • 2
    @unor a, area are not <link> elements and the specification is more than clear about the rel attribute. – Rob Feb 5 '17 at 0:41
  • Exactly, more than clear, which is why your statement is incorrect. The WHATWG HTML spec says about the link element: "If a link element has an itemprop attribute, or has a rel attribute that contains only keywords that are body-ok, then the element is said to be allowed in the body." – unor Feb 5 '17 at 15:47
  • @unor I have not bothered to study your link but I believe it is an exception to the rule that no one uses but "restricted to" is a pretty strong statement from the W3C you are saying is wrong. I will look at it further when I have a chance. – Rob Feb 5 '17 at 17:25
  • you can put link elements in the body element, but you can also drive a car with your feet. just because you can do something doesn't mean you should. clearly a violation of separation of concerns. the only times i'd do this if i were being forced to use schema.org's horrible implementations. and even then i'd fight it tooth and nail. why they didn't follow the path microformats blazed is beyond me. – albert Jul 13 '17 at 16:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.