Hugo: How to see draft posts in localhost

Published: 2020-01-22 19:48:44 -0500 -0500

Reading time: 1 mins (106 words)

Tags: hugo

problem

I use Hugo to statically-generate my sites and while writing / developing, it’s often useful to be able to see my posts even while they’re in draft mode (i.e. they have draft: true in their frontmatter). How can I get those draft posts to show up while I’m serving my site on localhost?

solution

To see these draft posts, we have to tell Hugo that we want it to output them. To do that, we can pass hugo the -D flag which tells it to render posts even if they’re drafts.

So to render your draft posts in hugo, you can run:

hugo serve -D

About the Ham

Hi I'm Hamilton and I wrote / built this! I like doing lots of things, but mostly I like to build (and then share those buildings). Some things I'm currently building: art, software, and prose. To stay up-to-date with my latest buildings, subscribe to my email list or follow one of my many other accounts. #buildit #shipit #justhamit

comments powered by Disqus