How to setup Drafts? (Drafts are broken when viewed locally) #91
-
Describe the bug When using Jekyll locally, drafts do not render properly. Screenshots Expected behavior Drafts work as intended. To Reproduce
Desktop (please complete the following information): Mobile devices (please complete the following information): Additional context |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments
-
This is caused of defaults setting in _config.yml. It set the page and blog post by path. Files in other paths like _drafts are not set. So any page in _drafts folder you need to set layout in _config.yml. Or just simply add this line _config.yml defaults:
# for posts
- scope:
# to separate language posts folders
path: "_posts"
values:
layout: "post"
permalink: /posts/:path
# for multilingual posts
- scope:
# to separate language posts folders
path: "*/_posts"
values:
hidden: true
layout: "post"
permalink: /:path For drafting your posts or any page you can use |
Beta Was this translation helpful? Give feedback.
-
Drafts are a pretty common use-case for a blog, is there a technical limitation that you're running into? Perhaps I could help figure it out. |
Beta Was this translation helpful? Give feedback.
-
I will explain this in as much detailed as I can, so that other people can benefit this as well. So What are drafts?
How to use drafts
if you don't use --draft option those pages will not be visible. I hope this helps |
Beta Was this translation helpful? Give feedback.
-
The drafts will show up on the related pages, but actually visiting the draft will cause all of the styling to break, and the path to not match the usual preset (e.g. I have mine configured for |
Beta Was this translation helpful? Give feedback.
-
Per reproduction steps, I already am using the |
Beta Was this translation helpful? Give feedback.
-
Ahhh, okay I figured it out actually. I needed to configure drafts to use the default permalink and layout like posts do: ###########################################################
# Front Matter Defaults (https://jekyllrb.com/docs/configuration/front-matter-defaults/)
###########################################################
defaults:
# for posts
- scope:
# to separate language posts folders
path: "_posts"
values:
layout: "post"
permalink: "/blog/:year/:month/:day/:slug/"
# for drafts
- scope:
path: "_drafts"
values:
layout: "post"
permalink: "/blog/:year/:month/:day/:slug/" The drafts now are rendering as expected with the above added to my config. |
Beta Was this translation helpful? Give feedback.
-
Yes it is permanent solution for _drafts folder. or just add |
Beta Was this translation helpful? Give feedback.
I will explain this in as much detailed as I can, so that other people can benefit this as well.
So What are drafts?
How to use drafts
title: Examples
totitle: New draft
in example.md file.layout: "post"
after this linetitle: New draft
.bundle exec jekyll serve --drafts --watch --host 0.0.0.0 --safe