How to add a new hugo static page?

AJcodez picture AJcodez · Feb 17, 2015 · Viewed 41.3k times · Source

From the "getting started" section it seems this should work, but it doesn't.

hugo new site my-site
hugo new privacy.md
hugo server --watch --includeDrafts

curl -L localhost:1313/privacy/index.html
# 404 page not found
curl -L localhost:1313/privacy.html
# 404 page not found
curl -L localhost:1313/privacy/
# 404 page not found

How can I add a new page?

Answer

revelt picture revelt · May 29, 2016

This is the best tutorial how to create static "landing pages" on Hugo: https://discuss.gohugo.io/t/creating-static-content-that-uses-partials/265/19?u=royston

Basically, you create .md in /content/ with type: "page" in front matter, then create custom layout for it, for example layout: "simple-static" in front matter, then create the layout template in themes/<name>/layouts/page/, for example, simple-static.html. Then, use all partials as usual, and call content from original .md file using {{ .Content }}.

All my static (landing) pages are using this method.

By the way, I'm not using hugo new, I just clone .md file or copy a template into /content/ and open it using my iA Writer text editor. But I'm not using Hugo server either, adapted npm-build-boilerplate is running the server and builds.