Random/Incorrect Image URL's Durring Each Build

By chance we discovered that during each build, Hugo would randomly inject a non-existing directory into an images URL causing a 404 for the image(s) and it is random to what links are broken. If we rebuild the site, the prior links that were incorrect would be corrected but other image links would have the injected directory. Rebuild again (seconds later), and other images would be broken and some fixed. This would happen without editing any files. There is no recognizable pattern to what images are broken during each build run. One would have to visit each page individually to find the 404’s.

Below is an example:

Hugo’s wrong generated link: /img/2017/122017/12/Blue_Front_Inn.jpg
The expected URL should be: /img/2017/12/Blue_Front_Inn.jpg

If you see in the example above, hugo would (sometimes) spontaneously add /12017/ directory to the URL - Obviously this is a date(?).

Take note that this didn’t start happening until the site would have about a dozen pages (built with the same single.html). The more blog pages added, the worst it becomes. Remove the pages (down to below the dozen threshold), the issue disappears.

Also, we have switched themes, run the build on different machines (windows, Linix, and on c9), and came to the same issue.

I am not sure where to go or look at this point. A colleague tried reporting a bug on GitHub, and the admin kept closing it saying it was not. So, any help here would be appreciated.

I can post any code here if you wish. I put up an open workspace on c9 at:



The only time I’ve seen non-deterministic output was when someone was mixing recursive template calls and Scratch (pro tip: don’t). Are the bad links always /img/year/monthyear/month/foo.jpg, as if ‘year/month’ is being included twice?


Right, that’s what it is doing. I had even went in and removes all the .Scratch functions from the intended theme but that didn’t do the trick. I contacted the theme developer too but haven heard back and the other theme we tested was doing the same thing -I haven’t been able to see if .Scratch is being used there.

If it does the same thing in multiple themes, then it’s unlikely to be the Scratch/recursion issue. I didn’t have any luck connecting to your C9 thingie, so maybe upload a simple tarball somewhere?