# Paginated pages don't show the correct URL in the meta canonical tag

**URL:** https://discourse.gohugo.io/t/paginated-pages-dont-show-the-correct-url-in-the-meta-canonical-tag/27124
**Category:** support
**Tags:** pagination
**Created:** [July 23, 2020, 2:18am UTC](https://discourse.gohugo.io/t/paginated-pages-dont-show-the-correct-url-in-the-meta-canonical-tag/27124 "2020-07-23T02:18:14Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![mickel1982](https://avatars.discourse-cdn.com/v4/letter/m/f14d63/32.png) [@mickel1982](https://discourse.gohugo.io/u/mickel1982)
#### Post date: [July 23, 2020, 2:18am UTC](https://discourse.gohugo.io/t/paginated-pages-dont-show-the-correct-url-in-the-meta-canonical-tag/27124/1 "2020-07-23T02:18:14Z")

</div>

Paginated pages don’t show the correct URL in the `<link rel="canonical" href="">` meta tag.

For example, `https://example.com/page/2/` shows `<link rel="canonical" href="https://example.com">` instead of `<link rel="canonical" href="https://example.com/page/2/">`.

How can I fix this?

On this moment, I only use `<link rel="canonical" href="{{ .Permalink }}">`.

---

<div class="post-metadata">

### Author: ![sephore](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/sephore/32/11673_2.png) [@sephore](https://discourse.gohugo.io/u/sephore)
#### Post date: [July 23, 2020, 2:55am UTC](https://discourse.gohugo.io/t/paginated-pages-dont-show-the-correct-url-in-the-meta-canonical-tag/27124/2 "2020-07-23T02:55:48Z")

</div>

Have you tried to use something like this:

```auto
{{ if (eq .Kind "section") }}
  <link rel="canonical" href="{{ .Paginator.URL | absURL }}">
{{ end }}

```

You could even add:

```auto
{{ if .Paginator.HasPrev }}
  <link rel="prev" href="{{ .Paginator.Prev.URL | absURL }}">
{{ end }}

{{ if .Paginator.HasNext }}
  <link rel="next" href="{{ .Paginator.Next.URL | absURL }}">
{{ end }}

```

---

<div class="post-metadata">

### Author: ![mickel1982](https://avatars.discourse-cdn.com/v4/letter/m/f14d63/32.png) [@mickel1982](https://discourse.gohugo.io/u/mickel1982)
#### Post date: [July 23, 2020, 12:21pm UTC](https://discourse.gohugo.io/t/paginated-pages-dont-show-the-correct-url-in-the-meta-canonical-tag/27124/3 "2020-07-23T12:21:27Z")

</div>

> [@sephore](#):
>
> ```auto
> {{ if (eq .Kind "section") }}
> <link rel="canonical" href="{{ .Paginator.URL | absURL }}">
> {{ end }}
> 
> ```

How can I use that with: `<link rel="canonical" href="{{ .Permalink }}">`?

My website’s template has `<link rel="canonical" href="{{ .Permalink }}">`.

---

<div class="post-metadata">

### Author: ![sephore](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/sephore/32/11673_2.png) [@sephore](https://discourse.gohugo.io/u/sephore)
#### Post date: [July 23, 2020, 12:34pm UTC](https://discourse.gohugo.io/t/paginated-pages-dont-show-the-correct-url-in-the-meta-canonical-tag/27124/4 "2020-07-23T12:34:50Z")

</div>

```auto
{{ if (eq .Kind "section") }}
  <link rel="canonical" href="{{ .Paginator.URL | absURL }}">
{{ else }}
  <link rel="canonical" href="{{ .Permalink }}">
{{ end }}

```

Please, read [Build the navigation](https://gohugo.io/templates/pagination/#build-the-navigation) for more information.

---

<div class="post-metadata">

### Author: ![mickel1982](https://avatars.discourse-cdn.com/v4/letter/m/f14d63/32.png) [@mickel1982](https://discourse.gohugo.io/u/mickel1982)
#### Post date: [July 24, 2020, 5:32am UTC](https://discourse.gohugo.io/t/paginated-pages-dont-show-the-correct-url-in-the-meta-canonical-tag/27124/6 "2020-07-24T05:32:10Z")

</div>

> [@sephore](#):
>
> ```auto
> {{ if (eq .Kind "section") }}
> <link rel="canonical" href="{{ .Paginator.URL | absURL }}">
> {{ else }}
> <link rel="canonical" href="{{ .Permalink }}">
> {{ end }}
> 
> ```

It’s not working.

---

<div class="post-metadata">

### Author: ![mickel1982](https://avatars.discourse-cdn.com/v4/letter/m/f14d63/32.png) [@mickel1982](https://discourse.gohugo.io/u/mickel1982)
#### Post date: [July 24, 2020, 5:43am UTC](https://discourse.gohugo.io/t/paginated-pages-dont-show-the-correct-url-in-the-meta-canonical-tag/27124/7 "2020-07-24T05:43:41Z")

</div>

I tried the following:

```
{{ if .Paginator}}
<link rel="canonical" href="{{ .Paginator.URL }}">{{else}}
<link rel="canonical" href="{{ .Permalink }}">
{{ end }}

```

And it seems to be working.

Is this a good way to do this?

---

<div class="post-metadata">

### Author: ![sephore](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/sephore/32/11673_2.png) [@sephore](https://discourse.gohugo.io/u/sephore)
#### Post date: [July 24, 2020, 1:10pm UTC](https://discourse.gohugo.io/t/paginated-pages-dont-show-the-correct-url-in-the-meta-canonical-tag/27124/8 "2020-07-24T13:10:06Z")

</div>

I don’t know how your site works. That’s why I asked you to read the documentation, as I said you could use “something like this”.

And you did.
