Hugo Posts not displaying
Asked Answered
D

2

12

Using Hugo Quickstart, I was able to up and running set up a blog and even wrote a post. When I run either hugo server -D or hugo server -D --watch --verbose I can see my post on localhost. But when I run only hugo server my blog loads only the Title and no posts. I have generareted the necessary files using hugo server. What should I do such that when I run hugo server everything loads?

Dialectical answered 22/8, 2018 at 20:12 Comment(1)
We need to see the code.Deflect
L
29

In your content/posts/, look for the field draft in the front matter(should be at the top of every file in posts folder). The front matter should be similar to

title: "My First Post"

date: 2018-08-14T20:08:02+05:30

draft: true

Replace true with false for draft. Now run hugo server and check. You should be able to see your post now.

It seems by default, the posts that are being created in your content folder have draft set as true. hugo will not show these as web pages by default as these are drafts and not ready for publishing yet. To show these drafts you have to pass -D flag to hugo server, which is why you are able to see your posts on running this command.

If you want to set draft as false for every newly created post, you will have to set draft field in archetype/default.md as false.

Linc answered 23/8, 2018 at 18:42 Comment(1)
This post actually helped on my main website, as I had forgotten to remove the draft boolean. Didn't know about the default.md thing though, might come in handy.Manatarms
S
0

Believe it or not: In my case, it did not work until I completely rebooted my machine. After that, the post was rendered. So maybe try this as well :-)

Savoie answered 22/7, 2022 at 6:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.