Hugo Will Not Rebuild Site after Syncing Gulp Changes

I’m working on a new site and am using NPM and Gulp to work with my SASS files.

I’m using Hugo v0.29, Node v6.11.3, NPM v3.10.10 for information’s sake.

Rather than using a pre-made theme, I’m just trying to build out a site structure from scratch.

I have an src folder with my SASS files.
In my static folder I have a css folder with the main CSS file for the site.
When I run Gulp, it does its thing with the SASS and punts out a new main.css file in the /static/CSS folder and then Hugo returns:

2017-09-30 23:23 -0700
Syncing \css\main.css to C:\Users\logan\documents\site\portfolio\

The livereload breaks and even if I manually hit reload, no changes have been made to the site. I don’t get the site rebuilding message from Hugo at all.

Here’s my gulpfile.js

var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');

//Variables
var input = './src/scss/**/*.scss';
var output = './static/css';
var sassOptions = {
  errLogToConsole: true,
  outputStyle: 'expanded'
};

var autoprefixerOptions = {
  browsers: ['last 10 versions', '> 5%', 'Firefox ESR']
};

//Tasks
gulp.task('sass', function () {
  return gulp
    // Find all `.scss` files from the `stylesheets/` folder
    .src(input)
    // Run Sass on those files
     .pipe(sass(sassOptions).on('error', sass.logError))
    // Write the resulting CSS in the output folder
    .pipe(autoprefixer())
    .pipe(gulp.dest(output));
});

gulp.task('watch', function() {
  return gulp
    // Watch the input folder for change,
    // and run `sass` task when something happens
    .watch(input, ['sass'])
    // When there is a change,
    // log a message in the console
    .on('change', function(event) {
      console.log('File ' + event.path + ' was ' + event.type + ', running tasks...');
    });
});

//order of operations
gulp.task('default', ['sass', 'watch']);

And my config.toml:

languageCode = "en-us"
title = "Logan Egbert"
description = "Portfolio Website of Logan Egbert"
publishDir = "docs"
layoutDir =  "layouts"
contentDir = "content"
source = "src"
staticDir = "static"

I’m guessing i’m missing something, but I’m new to Hugo and can’t really think of what.

Any help?

When you say the livereload breaks, do you mean it doesn’t activate, or does something bad happen, like a white screen or something?

If you aren’t seeing the Hugo rebuild message, it means it isn’t picking up the changes. If you stop Hugo and run it again, will it pick up changes from your gulp build? I am just confirming that Hugo is having a problem while running.

I am not 100% sure, but that looks wrong. Try removing it. I don’t think it is used that way.

It doesn’t activate at all.

At the moment, no it’s not. I changed some text color, gulp processed it and put the new main.css in the static folder with the corresponding changes. But when I close fire Hugo back up, it’s not taking the changes. How odd, this was not the case earlier today.

Here’s my Hugo verbose output:

INFO 2017/10/01 00:08:22 C:\Users\logan\documents\site\portfolio\static\ is the only static directory available to sync from
INFO 2017/10/01 00:08:22 syncing static files to C:\Users\logan\documents\site\portfolio\
WARN 2017/10/01 00:08:22 No translation bundle found for default language "en"
WARN 2017/10/01 00:08:22 Translation func for language en not found, use default.
WARN 2017/10/01 00:08:22 i18n not initialized, check that you have language file (in i18n) that matches the site language or the default language.
ERROR 2017/10/01 00:08:22 Failed to add template "404.html" in path "C:\\Users\\logan\\documents\\site\\portfolio\\layouts\\404.html": template: 404
.html:1: unexpected "{" in command
ERROR 2017/10/01 00:08:22 404.html : template: 404.html:1: unexpected "{" in command
Started building sites ...
INFO 2017/10/01 00:08:22 found taxonomies: map[string]string{"category":"categories", "tag":"tags"}
WARN 2017/10/01 00:08:22 [en] Unable to locate layout for "taxonomyTerm": [taxonomy/category.terms.en.html.html taxonomy/category.terms.html.html ta
xonomy/category.terms.en.html taxonomy/category.terms.html _default/terms.en.html.html _default/terms.html.html _default/terms.en.html _default/term
s.html indexes/indexes.en.html.html indexes/indexes.html.html indexes/indexes.en.html indexes/indexes.html theme/taxonomy/category.terms.en.html.htm
l theme/taxonomy/category.terms.html.html theme/taxonomy/category.terms.en.html theme/taxonomy/category.terms.html theme/_default/terms.en.html.html
 theme/_default/terms.html.html theme/_default/terms.en.html theme/_default/terms.html theme/indexes/indexes.en.html.html theme/indexes/indexes.html
.html theme/indexes/indexes.en.html theme/indexes/indexes.html]
WARN 2017/10/01 00:08:22 [en] Unable to locate layout for "taxonomyTerm": [taxonomy/tag.terms.en.html.html taxonomy/tag.terms.html.html taxonomy/tag
.terms.en.html taxonomy/tag.terms.html _default/terms.en.html.html _default/terms.html.html _default/terms.en.html _default/terms.html indexes/index
es.en.html.html indexes/indexes.html.html indexes/indexes.en.html indexes/indexes.html theme/taxonomy/tag.terms.en.html.html theme/taxonomy/tag.term
s.html.html theme/taxonomy/tag.terms.en.html theme/taxonomy/tag.terms.html theme/_default/terms.en.html.html theme/_default/terms.html.html theme/_d
efault/terms.en.html theme/_default/terms.html theme/indexes/indexes.en.html.html theme/indexes/indexes.html.html theme/indexes/indexes.en.html them
e/indexes/indexes.html]
ERROR 2017/10/01 00:08:22 Error while rendering "404": template: "404.html" is an incomplete or empty template
WARN 2017/10/01 00:08:22 template: "404.html" is an incomplete or empty template

Built site for language en:
0 draft content
0 future content
0 expired content
3 regular pages created
8 other pages created
0 non-page files copied
0 paginator pages created
0 tags created
0 categories created
total in 4 ms
WARN 2017/10/01 00:08:22 Skip i18nDir: GetFileAttributesEx C:\Users\logan\documents\site\portfolio\i18n: The system cannot find the file specified.
Watching for changes in C:\Users\logan\documents\site\portfolio\{data,content,layouts,static}
WARN 2017/10/01 00:08:22 Skip i18nDir: GetFileAttributesEx C:\Users\logan\documents\site\portfolio\i18n: The system cannot find the file specified.
Serving pages from memory
Web Server is available at //localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop

Got rid of this.

Did you run Hugo after removing source? I suspect that was the thing breaking yer site.

At any rate, to debug your config you’ll need to back it up, and then remove everything by the base values: baseURL, title, and theme if you have one. If Hugo works as expected, you know it is your config. If it still doesn’t work, it is likely something else. :slight_smile:

Yup, still busted :frowning:

Well, you have two options from here:

  1. Share a link to your site’s code, so I can clone it and test it on my machine, or
  2. Troubleshoot Hugo on your own, trying to figure out what broke

If you go for the second option, you might try starting a new Hugo site and seeing if that works, try installing Hugo on a new computer and see if that works, or try reinstalling Hugo.

I would get a simple, basic site working, without gulp, and then working up from there.

What I find missing in your output is the sentence like:

Watching for changes in C:\Users\logan\documents\site\portfolio{data,content,layouts,static,themes}

Do you perhaps have the watch variable set to false in your configuration file? That would explain why Hugo isn’t watching for changes.

(Your configuration file is in the root folder of your Hugo project and is named config.toml, config.yaml, or config.json depending on whether you use TOML, YAML, or JSON format for your configuration settings.)

I see you also have errors with the 404 page. I think you can address both issues by running Hugo like this:

hugo server --watch=true --disableKinds=404

This would enable Hugo’s watching and disable creating a 404 page (for now, just to rule out the error there).

Here’s the repository:

I’ll work on building a new site without a gulp pipeline in the interim.

Thank you!

Something is definitely wrong with Hugo.

I just made a new site with just an Index.html layout. When I make changes to the file, Hugo says:

2017-10-01 13:48 -0700
Template changed "C:\\Users\\logan\\documents\\github\\hugoportfolio\\layouts\\index.html": WRITE

However, it doesn’t write the changes and trigger livereload. I have to manually reload the site.

Very strange stuff.

I tried running hugo as you suggested and it made no difference. My config.toml file has no explicit watch = “false” instruction, but here is what i get when i run hugo config:

DEBUG 2017/10/01 14:29:09 Alias indexes to taxonomies
archetypedir = "archetypes"
baseurl = "http://example.org/"
blackfriday = &{Smartypants:true SmartypantsQuotesNBSP:false
ainIDAnchors:true Extensions:[] ExtensionsMask:[]}
builddrafts = false
buildexpired = false
buildfuture = false
cachedir = "C:\Users\logan\AppData\Local\Temp\hugo_cache\"
canonifyurls = false
cleandestinationdir = false
contentdir = "content"
datadir = "data"
debug = "true"
defaultcontentlanguage = "en"
defaultcontentlanguageinsubdir = false
defaultlayout = "post"
disable404 = false
disablealiases = false
disablelivereload = false
disablepathtolower = false
disablerobotstxt = false
disablerss = false
disablesitemap = false
enableemoji = false
enablegitinfo = false
enablemissingtranslationplaceholders = false
footnoteanchorprefix = ""
footnotereturnlinkcontents = ""
forcesyncstatic = false
hascjklanguage = false
i18ndir = "i18n"
ignorecache = false
ignorefiles = []
indexes = map[tag:tags category:categories]
languagecode = "en-us"
layoutdir = "layouts"
logi18nwarnings = false
metadataformat = "toml"
newcontenteditor = ""
paginate = 10
paginatepath = "page"
permalinks = map[]
pluralizelisttitles = true
preservetaxonomynames = false
publishdir = "public"
pygmentscodefences = false
pygmentscodefencesguesssyntax = false
pygmentsoptions = ""
pygmentsstyle = "monokai"
pygmentsuseclasses = false
pygmentsuseclassic = false
relativeurls = false
removepathaccents = false
rsslimit = -1
rssuri = "index.xml"
sectionpagesmenu = ""
sitemap = {ChangeFreq: Priority:-1 Filename:sitemap.xml}
staticdir = "static"
taxonomies = map[tag:tags category:categories]
themesdir = "themes"
title = "My New Hugo Site"
titlecasestyle = "AP"
uglyurls = false
usemodtimeasfallback = false
verbose = false
watch = false
workingdir = "C:\Users\logan\documents\github\hugoportfolio"

It’s definitely down to something in the ‘Theme’. I installed the theme ‘Minimal’ and ran Hugo and now livereload is working properly.

I wish I could figure out WHY this is happening when I try to create my own styling so I can get it right.

Anyone want to help?

A couple of things. First, I suggest you build this out like a theme, rather than in your site. Unless you are using gulp on your content, you should break it off into its own repo, so changes to your theme can be made without affecting the site content. It will make troubleshooting a lot easier, too!

Second of all, I cloned your site and it works fine for me. I am running gulp and hugo server. I get output like this:

[21:20:07] Using gulpfile ~/projects/temp/logan-portfolio/gulpfile.js
[21:20:07] Starting 'sass'...
[21:20:07] Starting 'watch'...
[21:20:07] Finished 'watch' after 12 ms
[21:20:07] Finished 'sass' after 114 ms
[21:20:07] Starting 'default'...
[21:20:07] Finished 'default' after 15 μs
File /home/maiki/projects/temp/logan-portfolio/src/scss/main.scss was changed, running tasks...
[21:21:37] Starting 'sass'...
[21:21:37] Finished 'sass' after 21 ms
File /home/maiki/projects/temp/logan-portfolio/src/scss/main.scss was changed, running tasks...
[21:22:24] Starting 'sass'...
[21:22:24] Finished 'sass' after 18 ms
Built site for language en:
0 draft content
0 future content
0 expired content
3 regular pages created
8 other pages created
0 non-page files copied
0 paginator pages created
0 tags created
0 categories created
total in 12 ms

Static file changes detected
2017-10-01 21:20 -0700
Syncing /css/main.css to /

Static file changes detected
2017-10-01 21:21 -0700
Syncing /css/main.css to /

Static file changes detected
2017-10-01 21:22 -0700
Syncing /css/main.css to /

But the first thing I did was fix the 404.html template. Could that be the issue for you? Have you tried fixing that and running gulp?

1 Like