zola: `draft` field does not draft an article.
Bug Report
I’m not sure this is a bug. I think I’m doing something wrong. I will apreciate any help.
Environment
Zola version: 0.8.0 System: Windows 10 with WSL (Ubuntu)
Expected Behavior
It should not render draft pages. (?)
Current Behavior
It render draft pages when I use {% for page in section.pages %}
in a section or index.
Step to reproduce
- Create a Zola website.
- Create a
index.md
template and use{% for page in section.pages %}
to list pages. - Put
draft = true
in a markdown file in thecontent
directory to try to draft it. $ zola serve
This is my code
The index.html
{% extends "base.html" %}
{% block content %}
<section>
<ul>
{% for page in section.pages %}
<li><a href="{{ page.permalink }}">{{ page.title }}</a></li>
{% endfor %}
</ul>
</section>
{% endblock content %}
My _index.md
under content/
+++
+++
And the article itself, also under content/
:
+++
title = "Article 1"
draft = true
date = 2019-07-10T14:00:00-06:00
+++
This is the content of article one.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 36 (1 by maintainers)
Commits related to this issue
- Do not load draft pages Part fix of #742 — committed to getzola/zola by Keats 5 years ago
- Do not load draft pages Part fix of #742 — committed to getzola/zola by Keats 5 years ago
- v0.9.0 (#720) * chore: Update toml to 0.5 everywhere Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com> * v0.8.1 * Update cli-usage.md (#729) * Update cli-usage.md * clarify tha... — committed to getzola/zola by Keats 5 years ago
This has now changed in the next branch: all drafts are now disabled by default unless a
--drafts
is passed to zola {build, serve, check}`. If anyone can give it a try it would be great!I stopped loading the drafts in the commit above in the next branch, very basic but at least it ensures drafts are not rendered.
The
next
branch should have a fully working draft system. Would be nice to have people testing the system to make sure it behaves as expected.Well, I’ll be damned. I recompiled Zola without the git link now and it worked. I either did something else wrong then, or something magically fixed itself since yesterday. Maybe some build tool required a system restart. Sorry for wasting your time.
Anyway, your code changes appear to be working as expected for my cases at least. 😃
Also, sorry ozkxr, you probably got a lot of off-topic messages from this github issue.
Now that drafts are only loaded in
serve
, I can probably remove all the other drafts check of the codebase and it should work as expected.I struggled with this a bit myself in zola.
The workflow with jekyll is what I expected, but didn’t find. It basically works like this:
I worked around this by adding a filter to the index template to omit items when drafts is True AND a custom config setting is True, then I use a different config for local vs deploy, which is sort of annoying to have to keep the two in sync.
I think it’d be great to have better support provided out of the box for this sort of “double standard” for rendered output.
Hmm I don’t use draft myself but don’t you want to actually look at it while working on it? If it’s not generated then you can’t do that.
On a second thought, it is working as intended: a draft page is not present in sitemap/rss/pagination but is present as a section child and you can filter them out in the templates with an if