Skip to content

Commit

Permalink
Hugo: fix home.Pages breaking change in v0.57.0
Browse files Browse the repository at this point in the history
Changelog for v0.57.0: https://github.com/gohugoio/hugo/releases/tag/v0.57.0

> `home.Pages` now only returns pages in the top level section. Before this release, it included _all regular pages in the site_. This made it easy to list all the pages on home page, but it also meant that you needed to take special care if you wanted to navigate the page tree from top to bottom. If you need _all regular pages_, use `.Site.RegularPages`. Also see gohugoio/hugo#6153.
> `.Pages` now include sections. We have added `.RegularPages` as a convenience method if you want the old behaviour. See gohugoio/hugo#6171 for details.
  • Loading branch information
Roboe committed Sep 28, 2019
1 parent beae0e9 commit d125914
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
6 changes: 5 additions & 1 deletion themes/virgulilla/layouts/_default/list.atom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@
</author>
{{- end }}
<generator uri="https://gohugo.io/" version="{{ hugo.Version }}">Hugo</generator>
{{- range first 15 (where .Data.Pages "Type" "in" .Site.Params.home.sections) }}
{{- $regularPages := .RegularPages }}
{{- if .IsHome }}
{{- $regularPages = (where .Site.RegularPages "Section" "in" .Site.Params.home.sections) }}
{{- end -}}
{{- range first 15 $regularPages }}
<entry>
<title>{{ .Title | plainify }}</title>
{{- with .OutputFormats.Get "HTML" }}
Expand Down
12 changes: 5 additions & 7 deletions themes/virgulilla/layouts/_default/list.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
{{ define "main" }}
{{- $var := newScratch }}
{{- if not .IsHome }}
{{- $var.Set "pages" .Pages.ByPublishDate.Reverse }}
{{- else }}
{{- $var.Set "pages" (where .Pages.ByPublishDate.Reverse "Section" "in" .Site.Params.home.sections) }}
{{- end }}
{{- $pages := .RegularPages.ByPublishDate.Reverse }}
{{- if .IsHome }}
{{- $pages = (where .Site.RegularPages.ByPublishDate.Reverse "Section" "in" .Site.Params.home.sections) }}
{{- end -}}
<main class="content" itemscope itemtype="http://schema.org/Blog">
{{ if not .IsHome -}}
<h1>{{ .Title }}</h1>
{{- end }}
{{ range $var.Get "pages" -}}
{{ range $pages -}}
<article class="content" itemscope itemtype="http://schema.org/BlogPosting">
{{ .Render "li-header" }}

Expand Down
2 changes: 1 addition & 1 deletion themes/virgulilla/layouts/partials/seo/opengraph.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
{{- $siteSeries := .Site.Taxonomies.series }}{{ with .Params.series }}
{{- range $name := . }}
{{- $series := index $siteSeries $name }}
{{- range $page := first 6 $series.Pages }}
{{- range $page := first 6 $series.RegularPages }}
{{- if ne $page.Permalink $permalink }}<meta property="og:see_also" content="{{ $page.Permalink }}" />{{ end }}
{{- end }}
{{ end }}{{ end }}
Expand Down

0 comments on commit d125914

Please sign in to comment.