Written by Fani Sánchez
Índice
What are the next and prev link elements?
The next and prev link elements are a markup suggestion for paging content that Google launched in December 2011. This markup takes the form of links and siven elements so that the search engine can distinguish which pages belong to the same series and their order.
As many other measures advised by Google, the next and prev link elements are recommended, but not mandatory. In addition, Google states that they act as suggestions, not absolute directives.
How should this marking be implemented?
Let’s imagine that we have an online electronics store and in the TV section we have up to 3 pages full of products. The correct way to implement the next and prev link elements in our web code would be as follows:
- Code contained in the first page/parent page (https://mydomain.com/section/)
<link rel=”next” href=”https://mydomain.com/section/page2” />
- Code contained in the second page or intermediate page
(https://mydomain.com/televisions/page2/)
<link rel=”prev” href=” https://mydomain.com/televisions/” />
<link rel=”next” href=”https://mydomain.com/televisions/page3/” />
- Code contained in the last page of the section (https://mydomain.com/televisions/page3/)
<link rel=”prev” href=” https://mydomain.com/televisions/page2/
/>
As you can see, in a marking of these characteristics, logical conditions are followed:
- The first page will only contain the rel=”next” markup element and not rel=”prev”.
- Intermediate pages will contain double markup to indicate the previous and next page, i.e. the link elements rel=”next” and rel=”prev”.
- The last page, on the other hand, will only contain the markup element rel=”prev” and not rel=”next”.
Next and prev and canonical link elements
The elements rel=”next” and rel=”prev” on the one hand and rel=”canonical” on the other hand are independent and complementary concepts. Both requests can be declared in the same page, for example, when we have paging that also has session variables. We cite the example provided by Google. If we have this page where ‘&page=” is the page variable and ‘&sessionid=’ is the session variable, which does not change the content and therefore would be duplicate content, we will suggest to Google with the following code that this is the second page of a series and that we want to index it without the session variable:
<link rel="canonical" href="https://www.example.com/article?story=abc&page=2”/>
<link rel="prev" href="https://www.example.com/article?story=abc&page=1&sessionid=123" />
<link rel="next" href="https://www.example.com/article?story=abc&page=3&sessionid=123" />
Other considerations
- Unlike other values (such as canonical), rel=”next” and rel=”prev” link elements can be relative or absolute URLs (as allowed by the
<link>
tag). And if a<base>
link is included in the document, the relative paths will resolve to the base URL. - These link elements will be declared in the section
<head>
, not in the document<body>
. - The use of rel=”previous” as a syntactic variant of rel=”prev” links is allowed.
- If we choose to use the link elements in a series of pages, all pages in the series must contain them. Otherwise, Google will invalidate the entire markup system and use its own logic to understand and index or not the content.