Error getting started: Expected valid escape code after \, but got 'W'. [recovered] panic: BUG: Expected valid escape code after \, but got 'W'"


#1

I’m trying to set up a website with the Academic theme, following the tutorial. I’ve tried about 3 different ways of getting a “Hello world,” running, including trying to run hugo on their pre-built websites, and manually adding the theme to a freshly-created website. Every time, I get the same error:

panic: BUG: Expected valid escape code after , but got ‘W’.

[recovered]
panic: BUG: Expected valid escape code after , but got ‘W’.

Following this is a very long Go stack trace, containing absolutely no information about what file is causing this error.

What does this error mean, and how can I get a basic webpage running?

I’m using Hugo 0.53.


#2

I’m on my phone so this is just a wild guess, but the following block in the example site’s config.toml might be causing it

office_hours = """
  Monday 10:00 to 13:00\\
  Wednesday 09:00 to 10:00\\
  Otherwise email to book an appointment
  """

#3

That’s it! You are a lifesaver, Zachary.


#4

@neutreno FYI, see above


#5

But it would be great if you created an issue here:


#6

Sure. Here we go:


#7

I just want to say that while looking into Hugo themes that are affected by this behavior of the TOML parser I came across the following comment in https://github.com/sethmacleod/dimension/issues/29:

I was writing a tool to mass-analyze Hugo themes and sites, and it pointed out an error with your theme.toml file. The two description fields have literal strings, but according to the spec, literal strings enclosed by one single-quote character cannot have newlines in them. See https://github.com/toml-lang/toml/blob/master/README.md#user-content-string.

You can make your strings legal like this:

description = '''
<!--[-->A fully responsive site template designed by <a href="https://html5up.net">HTML5 UP</a> and >released<!--]--><br />
<!--[-->for free under the <a href="https://html5up.net/license">Creative Commons</a> license.<!--]-->'

[…]
Really trivial, and I’m guessing the Hugo TOML parser accepts this syntax, but it’s best to follow the standard.

I’m just posting this here for reference.