Creating new site and theme skeletons with v0.118.0 and later

In Hugo v0.118.0 we improved the skeletons generated by the “hugo new site” and “hugo new theme” commands. Specifically, the “hugo new theme” command now creates a functional theme with sample content.

The theme is minimal, demonstrating basic features such as:

  • Directory structure
  • Content structure
  • Page bundles
  • Date localization
  • Menus
  • Taxonomies
  • Partial templates (including cached partials)
  • CSS inclusion
  • JavaScript inclusion
  • Static files

The new skeleton structure is useful for:

  1. Creating a new theme from a functional, minimally opinionated example
  2. Learning how Hugo works
  3. Testing

Although we may tweak the theme skeleton in the future, we intentionally excluded examples of intermediate and advanced features. The use cases described above require a simple, minimally opinionated starting point. Or to put it another way, please don’t submit pull requests to add examples of image processing, render hooks, etc.

To create a functional site and theme:

hugo new site mysite
cd mysite
hugo new theme mytheme
echo "theme = 'mytheme'" >> hugo.toml
hugo server

To create a functional site without a theme:

hugo new theme mysite --themesDir .
cd mysite
hugo server

If you need to create disposable test sites frequently, you can create an alias to do so. An alias is a shortcut that allows you to run a command by typing a shorter name. To create an alias for creating a new site and opening it in Visual Studio Code:

alias htest='hugo new theme testing --themesDir . && cd testing && code .'
16 Likes

A post was split to a new topic: Markdown to HTML problem

OK, but now my new site’s home page is full of lorem ipsum text. If I delete the content directory the site won’t render. Is there documentation somewhere that explains what I’m supposed to do next?

Let’s start by changing the content instead of deleting it.

I don’t get it. The site content goes in the site’s content directory. Why does the theme need content?

A theme doesn’t need content, but it can provide it.

https://gohugo.io/quick-reference/glossary/#component

The commands you typed created “a functional site and theme”. That theme happens to contain content so that the site is… functional.

Feel free to move the content directory up to the project level.

Thank you! That was the clarification I needed.