Following on from my previous post on the trials and tribulations of converting a Hugo site from markdown to asciidoc, I’ve now run into a seemingly unsurmountable new problem.
Having succesffully converted all pages to asciidoc; now, whenever I build the site, Hugo spits out an unending screed of section title out of sequence errors:
<snip>
ERROR 2020/03/30 11:23:02 2013-03-15-ios-prototyping-prerequisites.adoc: asciidoctor: WARNING: <stdin>: line 52: section title out of sequence: expected level 1, got level 3
ERROR 2020/03/30 11:23:02 2013-03-15-ios-prototyping-prerequisites.adoc: asciidoctor: WARNING: <stdin>: line 77: section title out of sequence: expected level 1, got level 3
ERROR 2020/03/30 11:23:03 2015-02-27-samsung-android-memory-error.adoc: asciidoctor: WARNING: <stdin>: line 48: section title out of sequence: expected level 1, got level 2
ERROR 2020/03/30 11:23:06 2012-05-12-getting-stuff-into-and-out-of-your-ios-devices.adoc: asciidoctor: WARNING: <stdin>: line 7: section title out of sequence: expected level 1, got level 3
ERROR 2020/03/30 11:23:06 2012-05-12-getting-stuff-into-and-out-of-your-ios-devices.adoc: asciidoctor: WARNING: <stdin>: line 17: section title out of sequence: expected level 1, got level 3
ERROR 2020/03/30 11:23:06 2012-05-12-getting-stuff-into-and-out-of-your-ios-devices.adoc: asciidoctor: WARNING: <stdin>: line 27: section title out of sequence: expected level 1, got level 3
ERROR 2020/03/30 11:23:06 2012-05-12-getting-stuff-into-and-out-of-your-ios-devices.adoc: asciidoctor: WARNING: <stdin>: line 35: section title out of sequence: expected level 1, got level 3
<snip>
I’m not 100% certain, but I suspect that this may be caused by the asciidoc parser getting confused by = signs in the TOML frontmatter of the pages. AsciiDoctor can be quite pernickerty about this kind of thing and does tend to output a lot of warnings, if given half the chance.
Anyway, whatever the reason is, the problem is that Hugo reports these WARNINGs from Asciidoc as ERRORs and then bails out without building the site:
Error: Error building site: logged XXX error(s)
However, in the meantime, the asciidoc parser has actually processed all the content files successfully, since there were only non-critical warnings generated. I can see the pages created in my public folder and, looking at the source code, they seem perfectly fine.
So, either:
- Hugo needs to distinguish between a
WARNINGcoming back from theasciidocparser and anERRORand not to abandon site building onWARNINGs only
or [this may already exist, I can’t find any likely-sounding option though]
- We need a way to run
hugo serverin a ‘standalone’ manner. That way I could at least test the site in a two-stage way by frst runninghugo serverand then [for example]hugo server --standaloneto test the generated site, which does exist even though Hugo thinks it failed to build.
Obviously the second option wouldn’t be ideal. But it would at least do for now, until a proper fix was implemented.
Anyone got any other suggestions?
EDIT:
Actually, another option might be to convert my frontmatter from TOML to one of the other formats which doesn’t use = signs. But, with over 350 pages on the site and a fair few of my own custom frontmatter tags involved, I don’t fancy the regex wrestling that would entail.
Plus, my theory about the cause of the errors being down to the frontmatter might turn out not to be the case, anyway.