Build Websites with Hugo: Code will not run in a working Hugo setup

Hello Brian,

I have some problems with running the code in your book. I like the style of the book very much and I have learnt a lot as a complete beginner with Hugo but quite experienced with linux. I bought the book a few days ago and I looking forward to reviewing it on amazon.

I have repeatedly failed to register with forum.devtalk.com. When I attempt to “Create New Account” the message “Incorrect username, email or password appears” nothwithstanding that each of these is ticked as OK beside the box. As a result, I am trying to contact you directly.
Finally, today I have discovered that if I use Chrome I can create a devtalk account! But not with FIrefox or Opera.

Setup:
$ cat /etc/os-release
NAME=“Linux Mint”
VERSION=“19.3 (Tricia)”
ID=linuxmint
ID_LIKE=ubuntu
PRETTY_NAME=“Linux Mint 19.3”
VERSION_ID=“19.3”
VERSION_CODENAME=tricia
UBUNTU_CODENAME=bionic

(base) ian…:~$ hugo version
Hugo Static Site Generator v0.68.3-157669A0/extended linux/amd64 BuildDate: 2020-03-24T12:13:38Z
(base) ian… :~$ go version
Command ‘go’ not found, but can be installed with: sudo apt install golang-go

Before I start I should point out that I can carry out all the tutorial and the demo site and downloaded code fines for the website: https://zwbetz.com/make-a-hugo-blog-from-scratch/

When I run up to page 8 in “Build Websiteswith Hugo” book “hugo server” I get the screen at bottom of p7 as expected with localhost:1313 in Firefox or Opera, both the latest.

As soon as I move on to "Creating Content using Archetypes to the end of the chapter the above commands give the same screen but without the “About” line which should be there.

When I run any of the code downloaded from the book website I get a blank screen and an empty index.html file generated in the public directory, This occurs in the setup above and a fresh install of LinuxMint20 with hugo installed from Synaptic.

I have run my entered code for “Kicking the Tires” in the above setup and also a fresh updated install of LinuxMint20 with hugo setup as above with the same problem of no About section.

The same behaviour occurs with different ways of installing hugo and updating hugo to the latest version, .74 I think, and updating golang.

I assume that something is wrong with the setup but it is odd that it occurs in two completely separate installs of Linux.

Please help me. I would send you copies of files but I am not sure where hugo keeps it logs and so on.

Below are some lines of code. I do not understand the warning message and whether it is relevant.

Kind wishes, Ian

#########################################################################

$ hugo version
Hugo Static Site Generator v0.68.3-157669A0/extended linux/amd64 BuildDate: 2020-03-24T12:13:38Z

~/hugo_sites/portfolio$ hugo server
Building sites … WARN 2020/09/10 15:45:39 found no layout file for “HTML” for kind “taxonomyTerm”: You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
WARN 2020/09/10 15:45:39 found no layout file for “HTML” for kind “taxonomyTerm”: You should create a template file which matches Hugo Layouts Lookup Rules for this combination.

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

Built in 3 ms
Watching for changes in /home/ian/hugo_sites/portfolio/{archetypes,content,data,layouts,static}
Watching for config changes in /home/ian/hugo_sites/portfolio/config.toml
Environment: “development”
Serving pages from memory
Running in Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop

############# Firefox output (About is missing )################

Brian’s Portfolio

This is my portfolio

On this site you will find

  • My biography
  • My projects
  • My resume

I have tracked down this problem thanks to a post by Derek A. Bentley on amazon.com about the book “Build Websites with Hugo” by Brian P Hogan
Throughout the provided code you will find the following comment by the publishers:
(!–
! Excerpted from “Build Websites with Hugo”,
! published by The Pragmatic Bookshelf.
! Copyrights apply to this code. It may not be used to create training material,
! courses, books, articles, and the like. Contact us if you are in doubt.
! We make no guarantees that this code is fit for any purpose.
! Visit http://www.pragmaticprogrammer.com/titles/bhhugo for more book information.
–)
NB replace the ( and ) at the beginning and end with angle brackets < >. I removed them otherwise the code does not show.
For some of the code to run this comment must be removed. I found that the whole comment had to be replaced with a blank like. If the comment is left in place many of the files will run but produce no output and there seem to be no error messages generated. I would suggest removing all these comments with a search and replace.
In the first chapter I found about 10 files with the above comment. Throughout all the files provided I ran a search and about 100 .html and .js contain the above comment.

I am concerned that the code has not been tested after the publisher’s copyright comment was added. I think it would be quite hard for a complete beginner to sort out this problem, I guess that this is an errata. There is another website related to this book not forum.devtalk.com that seems to have a long list of errata to this book but I could not see the problem that I identify here included there.

I canot repoduce my problem with the About page exercise in the chapter 1, Kicking the Tyres. I would like to edit that out from my orginal post. I can seen no way of editing posts.

I can find all the comments that are causing the example code not to run by running ripgrep with a regular expression:
<!--(\n.*){2}Pragmatic Bookshelf(.*\n){5}-->
maybe run this with the multiplatform ripgrep (rg):
rg --multiline '<!--(\n.*){2}Pragmatic Bookshelf(.*\n){5}-->' --context 4 or
rg --multiline '<!--(\n.*){2}Pragmatic Bookshelf(.*\n){5}-->' --replace ' ' --context 4

I can confirm that after removing all these comments the example code run just fine.

Hi Ian. Yea I’m really sorry about the code issues. The tooling we use for the book puts those disclaimers in and Hugo really doesn’t like those, so it results in these kinds of issues. I am trying to work up a proper solution to make this much easier for y’all.