Using draft to describe upcoming presentations

I use the blogging system to host my presentations (this can be seen at https://snicoll.be).

I’d like to create a page in advance for presentations that have been confirmed in the future. I’d like to show them in a separate section in the home page. Something like “Upcoming presentations” with a list of presentation name and date.

I’ve created a page in the presentations section with draft: true in the front matter. Then I’ve using the following to loop over them:

{{ range where (where .Site.AllPages "Section" "presentations") "Draft" true }}

I must be using this in a wrong way as this doesn’t yield anything. Perhaps because Hugo doesn’t render draft page by default or something? I could use another tag, but then I would not to filter it out so that it doesn’t show in the list of (past) presentations.

Is there a better way to handle this? Of course the ideal would be that the presentation would “move” to the right section once the date of the conference has passed but I am ok with having to rebuild by changing a flag.

Thanks!

AFAIK, draft is used to mark pages that are not ready for publishing, and are excluded from the production builds unless you use the --buildDrafts flag. (Similarly, posts with a publishdate that’s in the future are excluded unless you use the --buildFuture flag for your build)

Thinking loud about the problem a bit, maybe you could:

  • have all posts in the same section, the date of the upcoming talks obviously is in the future
  • use the buildfuture flag include these posts in your build
  • write a small javascript code that compares the current date and the date of the post, and adds a css class to future posts
  • add the Upcoming text or something similar from css to the title of future posts
    That way you wouldn’t have to rebuild the site.

Thanks, that’s interesting. I did build things statically using a separate flag. Rather than using draft, I am using an “upcoming” flag. This means I have to discard them in the usual list page. It’s not too bad as things are already centralised.

The commit is Render upcoming presentations · snicoll/snicoll.be@fc0934d · GitHub

It seems like a custom date field (e.g., presentation_date) in front matter would be easier to work with.
https://gohugo.io/templates/introduction/#example-show-future-events.

And if your front matter is TOML the custom date fields are time.Time values, which makes comparisons a bit easier.

1 Like