Hugo: UTF-8-BOM In Layouts Results In Blank Page

Created on 1 Jul 2018  路  3Comments  路  Source: gohugoio/hugo

Hugo Version: v0.42.2 windows/amd64 BuildDate: 2018-06-28T12:36:53Z
OS: Windows 10

When certain layouts files start with a BOM the pages fail to render. This does not impact all files though.

Our layout folder contains:

  • _default

    • baseof.html

    • home.html

    • section.html

    • single.html

  • partials

    • services.html

  • shortcodes

    • partial.html

The shortcodes and partials work perfectly fine when they have a BOM. In _default baseof.html works fine with a BOM, however home, section & single do not. When they have a BOM the rendered page is just blank. All our content files have BOMs.

The home, section and single files are really simple and look like:

{{ define "main" }}
    {{ .Content }}
{{ end }}

Other people have had this problem https://discourse.gohugo.io/t/baseof-html-block-templates-and-list-types-results-in-empty-pages/5612/12

This can obviously be fixed by changing the encoding of the file but all our projects are standardised on with a BOM so it would be great if all files could be the same.

Bug Keep

Most helpful comment

@bep Just wanted to say thanks for reviewing and fixing this. Hugo is a great tool and all the work done on it is really appreciated!

All 3 comments

This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help.
If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.
If this is a feature request, and you feel that it is still relevant and valuable, please tell us why.
This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.

This looks like a bug in Go: https://github.com/golang/go/issues/28482

I will work around it at our end by trimming away the BOM marker before we send it to the Go parser.

@bep Just wanted to say thanks for reviewing and fixing this. Hugo is a great tool and all the work done on it is really appreciated!

Was this page helpful?
0 / 5 - 0 ratings