rel-canonical prev/next when head can not be written

211 views Asked by At

Were working in a component(module)/template framework.

There is only one template per page, this defines the basic structure and layout. the HEAD area is defined here.

Now, many of our components(modules) include some concept of pagination. Thus, it's desired to use rel-next and rel-prev in the head of the document.

The problem comes from the template is (and cannot) be aware of the component that provides pagination. They are 100% completely decoupled.

Once the component is run, the head part of the page is typically flushed already. It's just a limitation of the framework.

since placing the links in the BODY (where the component(module) renders) will not achieve the correct results (i.e. Google ignores it unless in the head).

Can anyone think of an approach or work-around to this issue?

2

There are 2 answers

1
unor On

You could send HTTP Link headers instead:

Link: <http://www.example.com/favorite-books/everything-on-one-page>; rel="canonical"
Link: <http://www.example.com/favorite-books/page-1>; rel="prev"
Link: <http://www.example.com/favorite-books/page-3>; rel="next"

According to Google’s documentation about their usage of canonical, it’s supported.

While support isn’t mentioned on Google’s documentation about their usage of prev/next, support was confirmed in a thread on their product forums.

0
Grazerbeam On

According to Google the default option is to nothing - "Leave whatever you have exactly as-is. Paginated content exists throughout the web and we’ll continue to strive to give searchers the best result, regardless of the page’s rel=”next”/rel=”prev” HTML markup—or lack thereof."

Other more up to date mentions of the issue suggest the advice hasn't change: