Hugo 0.57.0 issue with draft = true

I ran into an issue with draft pages using hugo-0.57.0.

Error: 
...
executing "_default/list.html" at <.Content>: error calling Content: runtime error: invalid memory address or nil pointer dereference

Given the test case in this repo:

hugo-0.56.3 server -w
                   | EN  
+------------------+----+
  Pages            |  6  
hugo-0.57.0 server -w
                   | EN  
+------------------+----+
  Pages            |  8  

The difference is a page with

+++
draft = true
...
+++

When this page is renderd with {{ .Content }} the error above is thrown.

Is this a bug or do I have to check .Draft to make sure .Content is not used on draft pages?

This has already been reported here: The most recent draft article is being partially included in non-draft builds in 0.57.0

And there is the relevant GitHub issue over here: https://github.com/gohugoio/hugo/issues/6213

That was fixed with commit 9475f61

The fix will be available in v.0.57.1 that will be released in the coming days.

Hi onedrawingperday

My issue has nothing to do with taxonomies (as in

)

A bit harsh just to close my post …
I remove the test case git repo

Hello @it-gro

First of all I made the message you sent me public and I merged it with your topic.

I certainly apologize. The topic did seem as a duplicate at first and as such it was closed.

There was no harshness or anything of the sort, since duplicate topics are usually closed, at least as far as I am concerned.

Now to the topic on hand. I tested your repo and I noticed a couple of things.

First of all the draft true parameter is entered in the _index.md of a section called /test/ in Hugo 0.57.0 the creation of sections has changed.

Only @bep can give a reply whether what you describe is a bug or a breaking change.

However in my humble opinion why would someone enter draft = true for an entire section

Now regarding the ERROR about executing "_default/list.html" at <.Content>: error calling Content: runtime error: invalid memory address or nil pointer dereference I did notice that you tried to call .Content on its own (here and here) without it being within the range of some kind of Page collection.

It seems that since that section is a draft then somehow Hugo still thinks it is (even if it is created in 0.57) and hence the nil pointer dereference

Again there was no intention to offend.

2 Likes

Looks like the fix for draft=true crash still needs some fine-tuning. I have opened an issue to track this for probably a different flavor of this crash:

1 Like

Looks like mine is the same issue.

I am preparing a landing page for an XYZ series taxonomy for a not-yet published posts from that series. So I have the _index.md for that XYZ series taxonomy marked as draft too. I wouldn’t want the landing page to be published even before I have the posts in that series ready.

@it-gro

The following quote is from over here

We don’t support β€œdraft” (or expired etc.) for _index.md files.

You can follow the discussion directly at the GitHub issue that @kaushalmodi opened:

You are quick!

The following quote is from over here

For readers who do not follow that issue, that β€œquote” was created a minute ago :slight_smile:

I was replying to that reply from bep and was requesting him to support drafting _index.md. I hope he accepts this as a practical scenario that should be supported.

Indeed. :rocket:


Update from said GitHub issue:

Marking _index.md as draft is now under consideration

I have added a PR that should come close to the old behaviour. This most likely also fixed the crash that @regis experienced, which I’m more happy about.

1 Like

Thx!

Here’s my use case for draft in list pages (_index.md) - since this is questioned

content/doc/csc/cloud/provider/
...
β”œβ”€β”€ aws
β”‚   β”œβ”€β”€ 3
β”‚   β”‚   └── _index.md
β”‚   └── _index.md
β”œβ”€β”€ azure
β”‚   β”œβ”€β”€ 3
β”‚   β”‚   └── _index.md
β”‚   └── _index.md
β”œβ”€β”€ _index.md
...
└── saas
    β”œβ”€β”€ github
    β”‚   └── _index.md
    β”œβ”€β”€ gitlab
    β”‚   └── _index.md
    └── _index.md

Now for this file content/doc/csc/cloud/provider/_index.md
with

draft = false
=>

work-003

with

draft = true

=>
work-004

So I can disable the β€œList Content” (not good enough for publishing), but the structure is still maintained.
Perfect for my documents …

Worked up to 0.56.3 while 0.57.0 gave the above error.
I could add this workaround 6215 in the theme - but I would still need the draft=true support for _index.md

This issue was addressed in commit 6ccf50e and the fix was released in Hugo v.057.1

2 Likes

Hello,

I just upgraded to 0.57.1, and i experience the same problem (section was not rendered in 0.56.x and is now rendered in 0.57.1).

My section (derib/) is only 2 files _index.fr.md & _index.en.md.

My 2 files are just a front matter

---
title   : "DΓ©coration par Derib"
url     : derib
draft   : true
---

So as this use case (draft for section) is told to be fixed in the latest version, may be this is related with the section being multi-lingual ?

I’ll keep searching.

The sections/taxonomies are rendered, the content is not.

1 Like

OK. Thanks. Makes perfect sense.
So i’ll change my logic, no problem.

Keep up the great/good work. Thanks again.

Whether it makes β€œperfect sense” I’m not sure about, but it’s the current behaviour.

1 Like

Actually I was having the same question:

In /content/blog/_index.md I have draft: true. But exactly the same number of pages is rendered (list of all articles + each article).

I was hoping that drafting an _index.md file would not publish the list and remove it from the sitemap.

Currently, I use an individual param no_index: true which has the same effect.

Sorry if this question is redundant: Is it correct that drafting an _index.md is not intended for such use cases? (I am on 0.57.1, too.)