I am looking for ways to make some of the posts on my blog visible only to myself but can't seem to this in Hugo.
Is there any way around this such as setting a password for certain posts?
Or is the feature supported but I just haven't found it?
I am looking for ways to make some of the posts on my blog visible only to myself but can't seem to this in Hugo.
Is there any way around this such as setting a password for certain posts?
Or is the feature supported but I just haven't found it?
Since Hugo just generates the static HTML, the question can be widened to: how to password-protect any static content on the web server.
That's doable.
It depends what is your web server using: Apache or Nginx or something else.
In Apache case, set up password authentication via .htaccess
. See tutorials like this.
In Nginx case, set up password on your server block section, see tutorials like this.
For other server (IIS?), google accordingly.
Some people will want to downgrade this question, but in my opinion it's very valid, for example, if you want to post portfolios, CV's and whatnot on your personal website and limit public access
Make a landing page on Hugo site, password-protect the URL and give visitors the password. Easy, fast and still static!
My way to keep posts private is to set the draft flag in the front matter:
TOML
draft: "true"
A good practise for me is to connect a local instance of Hugo with GitLab/GitHub. If you want to see your website or a specific post as a rendered version you can turn on and off the visibility of pages using the draft flag with true and false.
If you have finished your tests you can push the final version with or without the draft flag active to the repo and sync it with your server side installation of Hugo.
Posts are displayed in multiple places (RSS feeds, search results, sitemap etc.).
Here is an article with an updated checklist and a solution to publish hidden posts with Hugo
git clone --recurse-submodules [email protected]:RoneoOrg/hugo-offtherecord-demo.git
cd hugo-offtherecord-demo
hugo serve
Set offTheRecord
to true
in the Front Matter of the posts you want to hide. That’s all!
See the source for details
Finally found the answer. Just add this information to your page frontmatter:
_build:
list: false
Note that this way, posts are only not shown in lists, sitemaps. However, this doesn't make your page protected by password.
Answer is taken from Hugo Discourse page.
© 2022 - 2024 — McMap. All rights reserved.