Why is Hugo serving blank pages?
I ran into the same issue after following the hugo getting-started / quickstart guide but instead of using an existing theme i created a very basic theme:
- Install hugo i picked install hugo on windows
- Create a New Site
hugo new site quickstart
- Add a Theme
- cloning a theme (for example the ananke-theme ) is easier
<-- this is what the quickstart does and what i left out
- instead you can create a theme with
hugo new theme [your-theme-name]
which adds a theme skeleton inside your site-folder for exampleC:\Hugo\Sites\example.com
(see the screenshot)
- cloning a theme (for example the ananke-theme ) is easier
- Add Some Content
hugo new posts/my-first-post.md
- Start the server
hugo server -D --watch --verbose
After you created a theme files and folders should be under Sites/example.com/themes/your-theme-name/
. Since most of the generated files are (nearly) empty you have to edit a few of them before the quickstart sample is working.
Based on develop a Theme for Hugo i edited /themes/your-theme-name/layouts/index.html
<!DOCTYPE html>
<html> <body>
{{ range first 10 .Data.Pages }}
<h1>{{ .Title }}</h1>
<div>{{- .Content -}}</div>
{{ end }}
</body> </html>
Basic information about hugo taken from develop a Theme for Hugo
- Hugo configuration files (TOML, YAML or JSON) are located in the root of your site
- Hugo default: Markdown inside
content/
,- content files contain metadata (frontmatter) and text (/markdown) --> html to public/,
- example frontmatter attributes:
date, title, description, categories, tags
templates under
themes/
(orlayouts/
)- three types of templates:
single, list, partials
- theme templates under
/themes/your-theme-name/
and then under/layouts/
forindex.html
and under/layouts/_default/list.html
and/layouts/_default/single.html
- three types of templates:
HTML files will be written to the
public/
directory.
You may want to read the hugo theme documentation.
The problem is likely to be the theme - it is either missing or broken. Hugo does not come with any default/fallback theme if you fail to provide a working one.
Debugging guide:
- Check the
themes
folder, and follow the quickstart. - Try using another, simpler theme.
- It may only be a question of configuring the theme, you may read the hugo theme documentation too.
Please verify your config.toml file points to right theme.
If following Quick start tutorial, you might have forgot to run
echo 'theme = "ananke"' >> config.toml
I had the same problem when I cloned my blog from Github but didn't include themes submodules. Including submodules solved my problem:
git clone --recurse-submodules https://github.com/username/your-blog