.Site.Pages not working correctly with Hugo 0.18.1

I have a bug with Hugo 0.18.1 (and not with Hugo 0.17).
At first referenced here : https://github.com/spf13/hugo/issues/2869#issuecomment-270497779

  • I create a new .md page with “draft = true”.
  • I render the site (with a plain “hugo” command), the page is not generated (expected behavior as i don’t use the build drafts option).
  • I switch that page to “draft = false” (or i remove the line my new .md page).
  • I republish the site through hugo (same way than before).
  • The page is now generated (expected behavior OK), the index.html includes the new post (also expected) BUT the “latests” block doesn’t include the new post ! (my “latest” area is generated in the theme template with ‘{{ range $i, $p := (first 10 .Site.Pages) }}’ => .Site.Pages doesn’t include the new post).

I’ve reverted from 0.18.1 to 0.17, and i don’t have the problem with 0.17.
I’m running under archlinux (host) / docker containers (under alpine), but i don’t think this may be OS related.

As noted in the 0.18 release notes, .Site.Pages now include ALL pages, including taxonomy lists, section lists etc.

My guess is you don’t see your page because of the “first”.



Thanks for the suggestion.

I tryed (with 0.18.1) with .Site.RegularPages

  <div class="row">
    {{ range $i, $p := (first 10 .Site.RegularPages) }}
    <div class="col-md-12 col-sm-6 col-xs-12">{{ .Render "li_sm" }}</div>
    {{ if eq (mod (add $i 1) 2) 0 }}<div class="col-sm-12"></div>{{ end }}
    {{ end }}

But i still have the exact same behavior : post appearing on index.html but not in that “latest” area with .Site.RegularPages when undrafted.

edit : also tryed with just .Site.RegularPages instead of “first 10 .Site.RegularPages”, it that was whan you meant all in all, but still the same

  • Do you see some warnings when running with hugo -v?
  • Is your site source on GitHub so I can have a look at it? Or could you share it some other way?

Hey again.

I have two warnings with -v, but at first glance they seem to be unrelated :

WARN: 2017/01/05 00:32:41 template_i18n.go:45: Translation func for language en not found, use default.
WARN: 2017/01/05 00:32:41 template_i18n.go:45: Translation func for language en not found, use default.

An important note (maybe) i forgot to clearly state (and that’s why i was at first refering to the opened issue on github) : i’m running hugo in an always-running docker container, thus with the --watch parameter (but without the “server” option). I don’t have the problem when running hugo by hand each time.

OK, that changes it!! Then it is most likely the same cause as the GH issue. I will probably have time to look at that tomorrow, some time …

But I don’t understand what benefi the watch param give?

Idea is to have a publication chain with as few manual steps as possible.

Right now i upload a source folder in an online server.
That source folder is constantly monitored by an always-running hugo (watch parameter) (docker container 1).
Generated output is in another folder published by an nginx server (docker container 2).

That way i just have to upload the source folder (even with rsync) and that’s all, nothing to start / run to publish html files.
It could of course have been done differently (running hugo in local and publishing generated files) but seemed to me more automated that way.

1 Like