Site.BuildDrafts deprecation

On The Deprecations in 156 page the deprecation of .Site.BuilDrafts is explained.

Is there no way to find out if hugo was run in the -D mode? (I had been using this to enable some debugging information even on non-draft pages).

When I include the draft pages, other things change (e.g., with more pages, various lists pagenate differently), so I like to have a visual reminder.

The only way I can come up with is to create a dumy draft (and headless) page in e.g. content/isdraft.md and then:

{{ if site.GetPage "isdraft" }}
// we're in draft mode.
{{ end }}

Or something.

2 Likes

Thanks! That works. I should probably improve my workflow, rather than trying to cling to old ways of doing things.

Yea, well – we understood that removing this would probably break something, but Site.BuildDrafts felt very incomplete without also reporting on the other similar flags (build expired/future). We may find a place for all of those 3 in the API somewhere if enough people shout …

I appreciate that you care about the aesthetics of the system - it’s part of the reason I keep using it!

My use case is weird.

1 Like