wjh18 / hugo-liftoff

Minimal blog/portfolio theme with a focus on content creation and SEO best practices. An ideal choice for technical users jump-starting a personal brand.
https://hugo-liftoff.netlify.app
MIT License
93 stars 27 forks source link

Not compatible with hugo v0.123 #41

Open scotte opened 6 months ago

scotte commented 6 months ago

Describe the bug With hugo v0.123, this theme results in execute of template failed: template: partials/head/seo/seo.html:17:20: executing "partials/head/seo/seo.html" at <.Paginate>: error calling Paginate: pagination not supported for this page: kind: "page"

I don't know if it's the right solution, but I wrapped the code block here https://github.com/wjh18/hugo-liftoff/blob/master/layouts/partials/head/seo/seo.html#L17 with {{- if and .Page.IsNode .Page.Paginator -}} as recommended here https://github.com/gohugoio/hugo/issues/12080

I know this theme is no longer maintained, creating this for the next person who runs into this issue.

ZhenHuangLab commented 6 months ago

Thanks! It also worked.

Specifically, you can change this:

<title>
  {{- $paginator := .Paginate .RegularPagesRecursive }}
  {{- with .Params.seo_title -}}
    {{- . -}}
  {{- else -}}
    {{- .Title -}}
  {{- end -}}
  {{- with $paginator -}}
    {{ if and (gt $paginator.TotalPages 1) (gt $paginator.PageNumber 1) }}
        | Page {{ $paginator.PageNumber }}
    {{- end -}}
  {{- end -}}
  {{ if (or (and (ne .Type "posts") (ne .Type "projects") (not .IsHome)) (and (not .IsPage) (not .IsHome))) }} | {{ .Site.Title -}}{{ end -}}
</title>

into this:

<title>
  {{- if and .Page.IsNode .Page.Paginator -}}
    {{- $paginator := .Paginate .RegularPagesRecursive }}
    {{- with $paginator -}}
      {{ if and (gt $paginator.TotalPages 1) (gt $paginator.PageNumber 1) }}
          | Page {{ $paginator.PageNumber }}
      {{- end -}}
    {{- end -}}
  {{- end -}}
  {{- with .Params.seo_title -}}
    {{- . -}}
  {{- else -}}
    {{- .Title -}}
  {{- end -}}
  {{ if (or (and (ne .Type "posts") (ne .Type "projects") (not .IsHome)) (and (not .IsPage) (not .IsHome))) }} | {{ .Site.Title -}}{{ end -}}
</title>
grimmy commented 4 months ago

For other looking to make this work, you can override this directly without vendoring the entire theme. To do that just create the folders/directories layouts/partials/head/seo/ and drop the above code into seo.html