blogdown home page not showing toc of posts any more
Asked Answered
D

1

1

I am using blogdown 0.14 with a slightly modified hugo-lithium theme.

It seems that the home page of the blog created has changed.

It used to be a page with the toc of the posts, not it is a page with a link to a page where this toc is displayed.
Is there a way to get back the old behavior?

Dewayne answered 16/8, 2019 at 16:34 Comment(1)
You may try to apply the similar fix as github.com/yihui/hugo-lithium/commit/….Aarhus
D
1

That was mentioned an hour ago on twitter:

See gohugoio/hugoThemes issue 682 and gohugoio/hugoThemes issue 678

As stated in gohugoio/hugo#6153, Hugo 0.57.0 has a breaking change since now:
(Actually, 0.58.0 will have those changes, 0.57.2 has reverted some of those breaking changes)

home.Pages work like the other sections

Also due to gohugoio/hugo#6154 now:

.Pages include the sub sections

The above breaking changes were made for developing new features like Cascading Front Matter and will be also needed in the future.

However during local testing with Hugo 0.57.0 I noticed that plenty of theme demos currently on the showcase use .Data.Pages or just .Pages to render lists (particularly on the index page) and as a result the list pages of these themes now look weird.

The author of the lithium theme has been notified.

As Yihui Xie (Software engineer @rstudio) comments, the yihui/hugo-lithium fork already illustrates the kind of patch most themes will have to do.
Commit 6da5ac2:

The layouts/_default/list.html included before:

{{ range (where .Data.Pages "Section" "!=" "").GroupByDate "2006" }}    

Now:

{{ $pages := .Pages }}
{{ if .IsHome }}
{{ $pages = .Site.RegularPages }}
{{ end }}
{{ range (where $pages "Section" "!=" "").GroupByDate "2006" }}

As mentioned in "Hugo 0.57.2: A couple of Bug Fixes":

This release reverts the behavior for .Pages on the home page to how it behaved in 0.56, but adds a WARNING telling you what to do to prepare for Hugo 0.58.

In short, .Page home will from 0.58 only return its immediate children (sections and regular pages).

In this release it returns .Site.RegularPages.
So to prepare for Hugo 0.58 you can either use .Site.RegularPages in your home template, or if you have a general list.html or RSS template, you can do something like this:

{{- $pctx := . -}}
{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}}
{{- $pages := $pctx.RegularPages -}}
Dormeuse answered 16/8, 2019 at 16:44 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.