hugo new site minimal
cd minimal
mkdir -p layouts/foo
echo "<h1>Hello World</h1>" > layouts/index.html
echo "<h1>Hello foo</h1>" > layouts/foo/index.html
hugo
Though content doesn’t get rendered without a layout file, right!?
hugo new site ${1:-"testing"}
cd ${1:-"testing"}
mkdir content/foo
echo "# Hello from foo" > content/foo/index.md
hugo
The above doesn’t render anything and doesn’t even warn, at least in a way that tells me foo/index.md will not be shown. Tbh kindof expected hugo to assume {{ .Content }} for simplicity sake.
So the minimal way I’ve found of creating an arbitrary path is something like:
hugo new site ${1:-"testing"}
cd ${1:-"testing"}
mkdir layouts/_default
echo -e "<h1>Hello from layouts</h1>\n{{ .Content }}" > layouts/_default/single.html
mkdir content/foo
echo "# Hello from foo" > content/foo/index.md
hugo
For my https://github.com/kaihendry/shopfront project I need a special /success and /cancel page. At first I assumed I could do this simply from /layouts, but it appears not. Unless I am missing missing some other trick??
And then I have the next problem of trying to make sure /foo doesn’t appear in the sitemap not index.xml
hugo new site minimal
cd minimal
mkdir -p layouts/foo
echo "<h1>Hello World</h1>" > layouts/index.html
echo "<h1>Hello foo</h1>" > layouts/foo/index.html
hugo
WARN 2020/09/29 13:08:07 found no layout file for "HTML" for kind "taxonomy": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
WARN 2020/09/29 13:08:07 found no layout file for "HTML" for kind "taxonomy": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
mkdir content/foo
echo "# Hello from foo" > content/foo/index.md
hugo
WARN 2020/09/29 13:10:53 found no layout file for "HTML" for kind "page": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
WARN 2020/09/29 13:10:53 found no layout file for "HTML" for kind "taxonomy": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
WARN 2020/09/29 13:10:53 found no layout file for "HTML" for kind "taxonomy": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
The found no layout file for "HTML" for kind "page" is telling you that you need a layout file for the page kind, i.e. content/foo/index.md.
If you need to use a special layout for a special page, i.e. you want content/foo/index.md to not use _default/single.html, you need to specify a custom type/layout in your frontmatter.
Since the warning doesn’t tell you the culprit file missing a template, it’s pretty useless.
Anyway, without getting bogged down in this, if I want to create a /success or /cancel path with HTML on it, IIUC I need to create markdown in content/ with an accompanying layout. There is no way I can get away with a static HTML file, is there?
That’s inconsistent with people’s first experience of using hugo, when they do something like echo "<h1>Hello World</h1>" > layouts/index.html. That works.
Minute you try paths with /layouts, it silently fails. I find this confusing. Maybe I’m the only one.
Again Bep already gave you the right information to understand how it works:
Hugo, by defaults, creates pages for
* Each content file
* And some standard pages for home, sections and taxonomies (if no content file for them exists)
/foo does not match any of the above.