How can i create a private post?

Hello everyone.
As title, i want to create a post, but it shouldn’t show public as general posts that showed on index page, Only people has its url (look like share url) can view.
many thanks

Not sure how private it has to be (Hugo creates RSS feeds, sitemap etc., so it will show up somewhere), but the easiest way is maybe to:

  1. Create a special section, i.e. a content root folder where you put this content, let us call it private (/content/private)
  2. Filter out that section in the where clause for the home page (in layouts/index.html):
{{ range where .Data.Pages "Section" "!=" "private" }}


1 Like

As you said not sure if it post exist in rss or sitemap :D, How about set password for a specific post? With apache webserver it can solved with .htaccess. In Hugo, does it has the same approach?

You could force users to enter a password if they want to access a certain url. However, this needs to be done in the server config. Hugo’s built-in server is just a simple file-server that is only intended to be used as a local test server but not in a production environment.

Note that even with a password protected post your website could leak information through the summary in the RSS feed.

Thinking about it, here is how I would do it:

  • Hugo builds fast so I would just build it twice
  • Once with /content and then with /content_private (there are command line options for this)
  • I would then create a /content_private/.htaccess file with appropriate rules
  • If you build to /public and /public/private it all should kind of magically work

Or a variation of the above…

How much information of a post is contained in the RSS feeds, sitemap etc.? Is it possible to disable some of the features which could leak info?

Would it be possible to have the post public and to hyperlink a file in a private GitHub repository?