Help test browser errors etc. (new in next Hugo 0.50)

I have added some nice additions to Hugo’s source tree, which, if you can build from source, would be cool if you can take for a spin and tell me if it works or not. I’m not too interested in “it would be cool if this also could …” comments.

If you now run hugo server, you should

  • Get errors presented in the browser with the faulty line highlighted if possible
  • You should also not get any “stale content” in fast render anymore (i.e. if you navigate to a completely different page, it should still reflect the latest templates etc.)

Also note that I will do a couple more improvements in the error area, most notable to get a proper file with line numbers context for errors in content files and config.toml, see this commit message for more details:

12 Likes

i tested it and it works like a charm! The best thing is that after you solve an error the page refreshes instantly.

Thank you very much for this @bep!

3 Likes

Looks good! What about using overflow-x: auto; instead of overflow-x: scroll; for .highlight? In my quick tests I couldn’t produce any error that needed to be scrolled, however deactivated scrollbars were always visible.

Thanks. I’ll make a mental note to try that. A general note: I’m sure someone will eventually chime in to make it “prettier”, but my main motivation is currently to get the errors right.

On that note, looks like we might get this annoying bug fixed in the next Go version:

An additional note to the above, if you have not already noticed:

Template errors now has the full filename to the template (which is less confusing in theme situations), and it also gives you the base template if that’s where the error is.

2 Likes

I noticed and immediately thought: It would be handy if the error’s line number were appended with a colon to the full filename. Text editors with inbuilt terminals (e.g. VS Code) can open such file links and jump to the specified line number. I hope this doesn’t qualify as a "it would be cool if this also could …” comment. If it does, feel free to ignore it :slight_smile:

2 Likes

What is the exact syntax expected by these? (I don’t use in-editor-terminals).

For VS Code it’s

file:line[:column]

Atom and Sublime Text should have the same syntax judging from their command line help reference.

1 Like

I actually use that … Not sure why I don’t use the internal shell.

2 Likes

I’ve got this error when running go get or build -o hugo main.go:
common/loggers/loggers.go:39:16: undefined: jwalterweatherman.Counter

Anything I’m missing?

Try go get -u or something. It is a depenency issue. I’ll also assume that you use Go 1.11.

This is AWESOME!

4 Likes

Thanks took me sometime but @DirtyF saved me!

This is really another game changer. No more squinty eyes on the terminal.
I like that it mentions only the problematic file (partial for ex) and not the many other files using it.

:tada:

4 Likes

Late to the party but I cannot get this to work.

When I execute: go build -o hugo main.go I’m getting:

go
common/herrors/errors.go:23:2: cannot find package "github.com/pkg/errors" in any of:
	/home/alex/work/src/github.com/gohugoio/hugo/vendor/github.com/pkg/errors (vendor tree)


I then proceed with govendor sync from the root of the hugo directory but nothing happens the errors package is not added.

How to solve this?

Hugo doesn’t use govendor any more. You need to have at least go 1.11 installed, and follow the installation instructions. I recently shared my installation shell script in this forum too.

:point_right: How can i build a hugo extended binaries?

Thanks I hadn’t noticed that govendor is no longer used.

I got it working with your script! So thanks a lot @kaushalmodi

@bep Awesome work as always :+1:

I see some white background in the divs above, don’t see it in my Chrome … can you inspect the page and see where that is coming from?

Oh, and you’re going to really love this when I’m finished with my little project. I didn’t really realize the importance and quality of Hugo’s error messages until I saw them in the browser. Oh, and my current working branch is also the fastest Hugo to date …

3 Likes

They are in my GIF too :stuck_out_tongue:. I thought you designed those in.

Update: Well, those are scroll bars.

image

1 Like

Indeed these are scrollbars.

A note: I couldn’t get a proper terminal integration working in sublime text, but Hugo + VS Code is actually very nice. I need to investigate more time on this. Oh, and the “jump to the file and line” works beautifully and will be really useful. Thanks for the tip, I hadn’t thought about that. Note that this is in my “personal branch” – I will clean it up and get it merged in near future. I had to go through some hoops to get line numbers for errors in content files correctly calculated …

6 Likes