Hide a Page in Hugo

Option 1: Draft

The simplest way to hide a page when using Hugo is probably to set the post as a draft. This way, you still have the content ready to go for when you need it.

To hide a page by setting it as draft, so our drafts page:

Set Post as Draft Tutorial

 

Option 2: Hide from Posts List

You still want the page to be visible, but you don’t want to show it your blog posts list? Then we can stop the theme from rendering that summary.

This will most likely change per theme.

/themes/{theme-name}/layout/index.html

1
2
3
4
5
{{ range (.Paginate .Site.RegularPages).Pages }}
    {{ if ne .Title "My Post Title to Ignore" }} 
        {{ .Render "summary" }}
    {{ end }}
{{ end }}

This will skip over any post named “My Post Title to Ignore”. We used an if statement and said where post title is not equals to x.

Find any better ways? Let us know in the comments.