Hello,
how can I check if Home is paginated? In WordPress I can check this with is_paged(). I only want home and posts indexed. I need something like this:
{{- if and (eq .Type "page") (ne is_Paged()) }}
<meta name="robots" content="noindex, follow">
{{- else }}
<meta name="robots" content="index, follow">
{{- end }}
bep
2
if .IsNode
if eq .Paginator.PageNumber 1
Note that you cannot use any βandβ construct in the above, because that will fail if you are on a regular page.
1 Like
Thanks!
It looks awful but it works:
{{- if .IsNode }}
{{ $pag := .Paginate (where .Data.Pages "Type" "!=" "page") }}
{{- if eq $pag.PageNumber 1 }}
<meta name="robots" content="index, follow">
{{- else }}
<meta name="robots" content="noindex, follow">
{{- end }}
{{- else }}
{{- if eq .Type "page" }}
<meta name="robots" content="noindex, follow">
{{- else }}
<meta name="robots" content="index, follow">
{{- end }}
{{- end }}
bep
4
You could probably get it nicer with .Scratch. Also note that you can call .Paginator as many times as you want after it is created.
I will study the documentation. Thanks!