× Home
Canonical links for pagination pages - page/2, page/3 ...

Hugo - Canonical Pagination Links for Blog Posts and Tags

Canonical links for pagination pages

Avoid search engine indexing errors for pagination following pages with an adapted canonical link in the head of the web page. Adapt the rel=canonical header so that page/2 to page/x are also assigned correctly.

Search engines do not have time or the time for indexing a website must be as efficient as possible. For this reason, it is helpful for search engines if a rel=canonical header is available for the respective website. If a canonical URL is correctly labelled, only the original source is used for indexing by the search engines. This avoids that the same content on different pages is recognised by Google as duplicate content.

In the case of my blog, I had included the following link in the head of the website - specifically in the baseof.html:

   <link rel="canonical" href="{{ .Permalink }}">

This has given each web page a canonical URL. I didn’t think about the pagination pages at that moment. Google then pointed out duplicate canonical links to me because the same canonical URL was assigned for page/2 to page/x. The pagination page number needs to be included in the URL.

In my post - Hugo - Pagination for blog posts and tags - I have described the procedure for using two pagination on a website.

The following source code must be added to the baseof.html below the assignment to the $paginator variable - see in the post mentioned above - as follows:

{{ $href := .Permalink }}
{{ with $paginator }}
  {{ if gt .PageNumber 1 }}
    {{ $href = printf "%s%s/%d/" $.Permalink "page" .PageNumber }}
  {{ end }}
{{ end }}
<link rel="canonical" href="{{ $href }}">


The blog overview and also the tag overview of the blog posts thus also receive a correct canonical URL for subsequent pages.

Link list for this article

2 minutes to read
This post was created with Hugo version 0.91.2.

With the German language setting, comments are not displayed in the English version of the website and vice versa.

© 2022 - Frank Kunert  -  About me
A service from webdienste-kunert.de