Web Analytics Made
Easy - StatCounter

Jekyll: publish locally but not publicly.

It takes me a few days to write longer posts and I had this idea that there’s probably a way to generate the post locally, so I could see the formatting, but not publicly when I pushed the changes. I don’t want to write a long post, only to comment 90% of it out to track down missing tags later.

And there are some options! Well …. sort of.

The options are mostly discussed in this SO question and summarized below.

Option 1: create a drafts branch

This is what I am do now. I create a new branch from main and then create my new post, edit, and generate. To save the work, I push it to GitHub. When I am finished, I need to merge this drafts branch to the main branch.

Option 2: a liquid tag, published

I didn’t know about this option, that you can add a tag in the front matter

---
published: false
...
---

and the page will not generate in the _site folder -> no public view of this page. The downside? It will not generate in the _site folder, so you can’t see what the page looks like locally either.

Option 3: use the _drafts folder

I have done this before – put some notes or other rough stuff in the _drafts folder, and then when it is time to work on these notes, move the file to posts (or wherever public) to edit and generate locally. The downside? If I’m not finished, I need to move it back to _drafts before I commit and push.

© Amy Tabb 2018 - 2022. All rights reserved. The contents of this site reflect my personal perspectives and not those of any other entity.