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?
Hugo is one of the most popular open-source static site generators. With its amazing speed and flexibility, Hugo makes building websites fun again.
Hugo is a static site generator (SSG) written in Go (aka Golang), a high-performance compiled programming language often used for developing backend applications and services. Today, Hugo is capable of generating most websites within seconds (<1 ms per page).
To add a module as a dependency of a site, we have to run the command hugo mod get <module path> . Then add an entry for the module in site configuration (in a config. yaml or config. toml file).
Hugo takes caching a step further and all HTML files are rendered on your computer. You can review the files locally before copying them to the computer hosting the HTTP server. Since the HTML files aren't generated dynamically, we say that Hugo is a static site generator.
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.
Just tested OK with this on Hugo 0.13:
hugo new site my-site cd my-site hugo new privacy.md hugo server -w -D curl -L localhost:1313/privacy/
Note: You have to either use a theme or provide your own layout template to get something more than a blank page. And of course, some Markdown in privacy.md would also make it even nicer.
See http://gohugo.io/overview/introduction for up-to-date documentation.
I had a similar requirement, to add static page (aboutus
in this case). Following steps did the trick,
content/aboutus/_index.md
layouts/section/aboutus.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With