Hi! Due to a variety of reasonss I’m interested in using hugo just for simple html serving on localhost with sass support on the fly. I just want so serve almost static html pages (I don’t care about layouts, etc). I believed this will be a piece of cake… well struggling still after two hours.
I want something 10 times simpler: just serve a second html file with my current setup, that blogpost is using layouts, markdown and other things I’m not interested.
Your content directory doesn’t process template code (we use shortcodes instead in content). Try moving them to layouts, following where they would be in the template lookup. For instance, layouts/index.html will render your homepage.
@maiki is right in that you should put the HTML files in layouts. Honestly, you’d probably be better off using something like lite-server on NPM if you’re only interested in a simple HTTP server and livereload with SCSS compilation…
@maiki… my settings are just the default ones, nothing else. If you clone the repo and start the server you will see the index page is working, but I cannot get the other one to be served.
@rdwatters maybe, but hugo is just a binary, much less complexity and a perfect fit for what I need. Anyway it looks like such a simple usage…
You have content/index.html . This makes / a page bundle, specifically a leaf bundle. Which means content/page2.html is being treated as a page-type resource, which means it has no URL.
So I had a look at your repo. I’m really not sure how that could work without defining your layouts. What version of Hugo are you using? I would suggest, as the others above mentioned, to move the templating code into layouts. Doing so would also make it easier to get help from others in the forum, as that is the ‘usual’ use case.
It is quite easy to do. If your pages share the same basic form, you could just have two files:
layouts/_default/list.html and
layouts/_default/single.html
Taking the example of your content/_index.html.
copy the contents into layouts/_default/list.html and replace everything inside the <div class="container"> with {{ .Content }}
in content/_index.html add empty front matter and retain only the contents of <div class="container">
@pointyfar thanks for your reply, I’m using hugo v0.54.
I’ve moved my content/_index.html file to layouts/index.html and it worked. I don’t use layouts because I don’t need them, every file inside my contents is a complete html per se.
The only thing left is the ability to load partials: for example let’s say I have content/page2/index.hmtl and content/page2/header.html. I will like to insert header.html inside the first one by doing {{ partial "header.html" . }} but it cannot find the file (prefixing the path didn’t help also).
Any ideas how to do this inside content and not layouts?
@zwbetz thanks for your reply, but I want the “partial” html to be inserted to reside in the same directory… no in /layouts/shortcodes/<SHORTCODE>.html as the docs state about them.
Something more like to split big htmls into sections.