Script to create new debug site

I often find myself creating small sample sites when debugging a forum question. Most of them have the same basic setup, so figured I’d script it to save myself some time (relevant xkcd).
Sharing it on the off chance it’s useful for others.

Bash script


log() {
  echo "[$(date +'%a %Y-%m-%d %H:%M:%S %z')] $message"

usage() {
  echo "Usage:"
  echo "  $0 <site_name>"
  exit 1 

if [[ -z "$site_name" ]]; then 

log "Checking hugo version..."
hugo version 

log "Creating site..."
hugo new site "$site_name"
if [[ $? -ne 0 ]]; then 
  log "Error creating site, exiting..."
  exit 1 
cd "$site_name"

log "Creating homepage layout..."
cat << EOF > ./layouts/index.html
<h1>{{ .Title }}</h1>
{{ .Content }}

log "Creating homepage content..."
cat << EOF > ./content/
title: Home

Homepage content here. 

log "Creating single layout..."
mkdir -p ./layouts/_default 
cat << EOF > ./layouts/_default/single.html
<h1>{{ .Title }}</h1>
{{ .Content }}

log "Creating a few pages..."
for i in {1..5}
  hugo new page${i}/ 

log "Updating config file..."
cat << EOF >> ./config.toml
disableKinds = ["taxonomy", "taxonomyTerm"]

log "Generating site..."
hugo -D 

Example usage
$ ./hugo_new_debug_site.bash 
  ./hugo_new_debug_site.bash <site_name>

$ ./hugo_new_debug_site.bash some-site
[Fri 2019-05-03 12:04:19 -0500] Checking hugo version...
Hugo Static Site Generator v0.55.5-A83256B9C/extended darwin/amd64 BuildDate: 2019-05-02T14:10:20Z
[Fri 2019-05-03 12:04:19 -0500] Creating site...
Congratulations! Your new Hugo site is created in /Users/zwbetz/Development/Sites/some-site.

Just a few more steps and you're ready to go:

1. Download a theme into the same-named folder.
   Choose a theme from, or
   create your own with the "hugo new theme <THEMENAME>" command.
2. Perhaps you want to add some content. You can add single files
   with "hugo new <SECTIONNAME>/<FILENAME>.<FORMAT>".
3. Start the built-in live server via "hugo server".

Visit for quickstart guide and full documentation.
[Fri 2019-05-03 12:04:19 -0500] Creating homepage layout...
[Fri 2019-05-03 12:04:19 -0500] Creating homepage content...
[Fri 2019-05-03 12:04:19 -0500] Creating single layout...
[Fri 2019-05-03 12:04:19 -0500] Creating a few pages...
/Users/zwbetz/Development/Sites/some-site/content/page1/ created
/Users/zwbetz/Development/Sites/some-site/content/page2/ created
/Users/zwbetz/Development/Sites/some-site/content/page3/ created
/Users/zwbetz/Development/Sites/some-site/content/page4/ created
/Users/zwbetz/Development/Sites/some-site/content/page5/ created
[Fri 2019-05-03 12:04:20 -0500] Updating config file...
[Fri 2019-05-03 12:04:20 -0500] Generating site...

                   | EN  
  Pages            |  7  
  Paginator pages  |  0  
  Non-page files   |  0  
  Static files     |  0  
  Processed images |  0  
  Aliases          |  0  
  Sitemaps         |  1  
  Cleaned          |  0  

Total in 10 ms


I’m gonna be pissed when this comes to bite us in the ass when no one shares repo links any longer as the #support helpers can just produce new hugo sites to test their five lines of code shared in a screenshot… :stuck_out_tongue_winking_eye:


No kidding :stuck_out_tongue_winking_eye:. Will have to keep it on the down low

1 Like

We may need a new support forum to support the supporting support script for supporters. :joy:


May be the script should just git clone a debug website.

I usually just clone, modify and push to a new remote for new Hugo issues. Example:

1 Like

Anddd that’s a better idea lol

I made a repo with a very small site to test themes in continuous integration tools a while ago; I guess this could be used for debugging purposes as well. It currently doesn’t completely fit the use case: because it is used to test themes, it doesn’t have its own layouts. Of course, I’m open to suggestions for improvements!

The repo is here:


Depends. I’m usually unable to provide the repo or the site. Only the public version of my site is visible, and I wouldn’t push to it unless everything is working. My repos are private, although I suppose I could fork them and post them. I’m gonna look at what zwbetz provided, and work up something that’s in between a useless sample and a full site. That is, after I clean all the cruft out of my existing site!

Took the hint from @kaushalmodi and made it into a git repo.

1 Like

You can use the debugbar or my debugprint component in there :slight_smile:

Here’s my version of a similar site: (with pictures and bundles too).

1 Like

Nice. I like that you give the key data type too (among other things, can tell that you put some work into this bad boi)