Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Mandel <markmandel@google.com>2019-06-26 23:31:06 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-06-26 23:38:30 +0300
commit88c8a15be18a0bd1bd9b9cb175f7a68f2b9cd355 (patch)
tree8cca39f1b094f3265ab8a76cf8f893026bb43838
parent59c4bc52ed6b146baa6cca97d054004297ea098a (diff)
Pagination - do not render href if no next item
When using a html link checker with Hugo, this template consistently causes errors, as it renders `href=""` attributes when next/previous is disabled. This change makes it so that the `href` attribute is not rendered at all if `HasNext` is false - which is better semantically, and makes link checking far easier.
-rw-r--r--tpl/tplimpl/embedded/templates/pagination.html6
1 files changed, 3 insertions, 3 deletions
diff --git a/tpl/tplimpl/embedded/templates/pagination.html b/tpl/tplimpl/embedded/templates/pagination.html
index 1c2d2d82f..896e655fe 100644
--- a/tpl/tplimpl/embedded/templates/pagination.html
+++ b/tpl/tplimpl/embedded/templates/pagination.html
@@ -7,7 +7,7 @@
</li>
{{ end }}
<li class="page-item{{ if not $pag.HasPrev }} disabled{{ end }}">
- <a href="{{ if $pag.HasPrev }}{{ $pag.Prev.URL }}{{ end }}" class="page-link" aria-label="Previous"><span aria-hidden="true">&laquo;</span></a>
+ <a {{ if $pag.HasPrev }}href="{{ $pag.Prev.URL }}"{{ end }} class="page-link" aria-label="Previous"><span aria-hidden="true">&laquo;</span></a>
</li>
{{ $ellipsed := false }}
{{ $shouldEllipse := false }}
@@ -29,7 +29,7 @@
{{ end }}
{{ end }}
<li class="page-item{{ if not $pag.HasNext }} disabled{{ end }}">
- <a href="{{ if $pag.HasNext }}{{ $pag.Next.URL }}{{ end }}" class="page-link" aria-label="Next"><span aria-hidden="true">&raquo;</span></a>
+ <a {{ if $pag.HasNext }}href="{{ $pag.Next.URL }}"{{ end }} class="page-link" aria-label="Next"><span aria-hidden="true">&raquo;</span></a>
</li>
{{ with $pag.Last }}
<li class="page-item">
@@ -37,4 +37,4 @@
</li>
{{ end }}
</ul>
-{{ end }} \ No newline at end of file
+{{ end }}