[Solved] How check if Home is paginated

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 }}

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 }}

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!