Zola version: next branch (commit d356a76a012d0ab56c4997c0584f6e53e82de66f)
The website should build.
The website builds when running zola serve but fails when running zola build with the following message:
-> Creating 8 pages (3 orphan), 4 sections, and processing 0 images
Failed to build the site
Error: Failed to render single term skills page.
Reason: Failed to render 'squat/templates/skills/single.html'
Reason: Page `_common/skills/html5.md` not found.
The source to the website can be found here.
Ah that's exactly what we were discussing with @awulkan on https://github.com/getzola/zola/issues/742
zola build does not render pages with draft = true but serve does. If the site is relying on that page then it should probably not be a draft
It seems like it's because you are trying to get a draft page. This was recently changed so that pages marked as draft wouldn't be published, and so that you didn't have to add a bunch of if statements everywhere to remove them from the rendering process.
Is there any reason why the page is a draft if you still want to use it in the built site anyway?
Ah, yes! I did not realize this, thanks!
I think this should be marked a breaking change in the CHANGELOG. Also, maybe we could do something to make the error more explicit?
Not sure about calling that a breaking change. Linking to a draft page was wrong before, now it is just enforced. I'm not sure we can actually get a better error message as the page is just not loaded so it's the same as linking to a random inexistent page.
I think the only way to give a better error message would be to keep track of all draft pages so that you could check if a non-existent page is a draft. But idk what would be the best solution for this, or if it could be implemented in a good way.
Another thing that could help would maybe be to explicitly mention it in the documentation that trying to get a draft page during zola build won't work.
Not sure about calling that a breaking change.
Not in the idea, but in practice it is.
if it could be implemented in a good way.
Is this ok?
src/cmd/serve.rs
ctrlc::set_handler(move || {
- remove_dir_all(&output_path).expect("Failed to delete output directory");
+ if remove_dir_all(&output_path).is_err() {
+ console::warn("Failed to delete output directory");
+ }
::std::process::exit(0);
})
In my case, it outputs the following:
Failed to build the site
Error: Failed to render single term skills page.
Reason: Failed to render 'squat/templates/skills/single.html'
Reason: Page `_common/skills/html5.md` exists but is not been loaded. If it's a draft, remember draft pages are not loaded when running the `build` command.
I think that's a lot more explicit.
Woops, sorry i copied the wrong diff.
components/templates/src/global_fns/mod.rs
match library.get_page(&full_path) {
Some(p) => Ok(to_value(p.to_serialized(&library)).unwrap()),
- None => Err(format!("Page `{}` not found.", path).into()),
+ None => {
+ match full_path.exists() {
+ true => Err(format!("Page `{}` exists but has not been load
ed. If it's a draft, remember draft pages are not loaded when running the `build
` command.", path).into()),
+ false => Err(format!("Page `{}` not found.", path).into())
+ }
+ },
}
```
Personally I would like draft pages to be excluded from zola serve (to be consistent with zola build) unless a parameter is passed in to particularly enable draft pages :)
I don't use drafts myself so but it looks like people have conflicting views on what zola serve should do :(
@kurji Most SSGs I've tried renders them by default, but I also see that some don't, like Hugo and Jekyll.
Personally I think it's easier to render hidden content by default, so that you don't have to remember a bunch of flags, but I guess it comes down to the kind of workflow you have.
If we in the future decide to also not render posts with future publish dates or passed expiry dates, like Hugo does, then we have three flags that must be toggled on to see all content.
So the question is, should hidden content be rendered by default, or explicitly toggled with flags.
I don't use drafts myself so but it looks like people have conflicting views on what
zola serveshould do :(
Maybe --production and --development flags would solve this?
To preserve current behavior:
zola serve might be --development by default.
zola build might be --production by default.
Looking at Hugo/Jekyll, they both have a --drafts or --buildDrafts flag for the build & serve. I don't really see the point of a zola build --drafts if anyone can explain it.
@ozkxr I would prefer a specific flag like --drafts
@Keats I agree. I think that's a better suited solution.
Just my two cents, but I'd like to keep zola serve showing drafts because I use that to review posts I'm writing. And I believe Drafts should not be rendered by zola build.
Ok is there a consensus on what behaviour should be in Zola?
serve and no way to change thatzola serve to render the drafts, otherwise they are not rendered by default, like in zola buildI would like to add a third option which zola serve render draft by default but a flag is added to exclude the rendering of the drafts.
EG:
zola serve renders everything including drafts
zola serve --exclude-drafts renders everything excluding drafts
I personally flavor this option.
My preference is for option 2 (consistent behaviour and same flag for both commands), then option 3 as second preference :)
The point of a zola build --drafts to me would be to publish the site for review of draft content, e.g. on a test server.
I would prefer to make zola build and zola build work the same way. (Option 2)
If the user/dev wants to include drafts, there's the --drafts flag working with both commands.
If the user/dev wants to use --drafts by default, I think aliases at shell level could be a solution.
Ok it looks like the majority likes the same option as me (2). It should be easy to implement if anyone wants to do it, otherwise I'll do it later.
zola check should also get the flag for consistency
It's implemented in the next branch if anyone wants to have a look
Most helpful comment
Looking at Hugo/Jekyll, they both have a
--draftsor--buildDraftsflag for the build & serve. I don't really see the point of azola build --draftsif anyone can explain it.@ozkxr I would prefer a specific flag like
--drafts