gohugoio/hugo

Minification breaks go-import/go-source meta tags

Closed this issue · 4 comments

What version of Hugo are you using (hugo version)?

$ hugo version
Hugo Static Site Generator v0.70.0/extended linux/amd64 BuildDate: unknown

Does this issue reproduce with the latest release?

Yes (v0.72.0)

When running hugo generation with --minify, quotes around the name attribute of a meta tag are lost, breaking go-import go get functionality.

~/src/gonum.org/website [master*]$ hugo --gc --minify

                   | EN  
-------------------+-----
  Pages            | 53  
  Paginator pages  |  0  
  Non-page files   |  1  
  Static files     | 10  
  Processed images |  6  
  Aliases          | 11  
  Sitemaps         |  1  
  Cleaned          |  0  

Total in 289 ms
~/src/gonum.org/website [master*]$ grep go-import public/index.html 
[nsip]<meta name=go-import content="gonum.org/v1/exp git https://github.com/gonum/exp"><meta name=go-import content="gonum.org/v1/gonum git https://github.com/gonum/gonum"><meta name=go-import content="gonum.org/v1/hdf5 git https://github.com/gonum/hdf5"><meta name=go-import content="gonum.org/v1/netlib git https://github.com/gonum/netlib"><meta name=go-import content="gonum.org/v1/plot git https://github.com/gonum/plot"><meta name=go-import content="gonum.org/v1/tools git https://github.com/gonum/tools"><meta name=go-source content="gonum.org/v1/exp https://github.com/gonum/exp/ https://github.com/gonum/exp/tree/master{/dir} https://github.com/gonum/exp/blob/master{/dir}/{file}#L{line}"><meta name=go-source content="gonum.org/v1/gonum https://github.com/gonum/gonum/ https://github.com/gonum/gonum/tree/master{/dir} https://github.com/gonum/gonum/blob/master{/dir}/{file}#L{line}"><meta name=go-source content="gonum.org/v1/hdf5 https://github.com/gonum/hdf5/ https://github.com/gonum/hdf5/tree/master{/dir} https://github.com/gonum/hdf5/blob/master{/dir}/{file}#L{line}"><meta name=go-source content="gonum.org/v1/netlib https://github.com/gonum/netlib/ https://github.com/gonum/netlib/tree/master{/dir} https://github.com/gonum/netlib/blob/master{/dir}/{file}#L{line}"><meta name=go-source content="gonum.org/v1/plot https://github.com/gonum/plot/ https://github.com/gonum/plot/tree/master{/dir} https://github.com/gonum/plot/blob/master{/dir}/{file}#L{line}"><meta name=go-source content="gonum.org/v1/tools https://github.com/gonum/tools/ https://github.com/gonum/tools/tree/master{/dir} https://github.com/gonum/tools/blob/master{/dir}/{file}#L{line}">[snip]

c.f. the correct un-minified output which retains the name attribute quoting.

~/src/gonum.org/website [master*]$ hugo --gc 

                   | EN  
-------------------+-----
  Pages            | 53  
  Paginator pages  |  0  
  Non-page files   |  1  
  Static files     | 10  
  Processed images |  8  
  Aliases          | 11  
  Sitemaps         |  1  
  Cleaned          |  0  

Total in 299 ms
~/src/gonum.org/website [master*]$ grep go-import public/index.html 
  <meta name="go-import" content="gonum.org/v1/exp git https://github.com/gonum/exp">
  <meta name="go-import" content="gonum.org/v1/gonum git https://github.com/gonum/gonum">
  <meta name="go-import" content="gonum.org/v1/hdf5 git https://github.com/gonum/hdf5">
  <meta name="go-import" content="gonum.org/v1/netlib git https://github.com/gonum/netlib">
  <meta name="go-import" content="gonum.org/v1/plot git https://github.com/gonum/plot">
  <meta name="go-import" content="gonum.org/v1/tools git https://github.com/gonum/tools">

See also post at golang-nuts https://groups.google.com/d/msg/golang-nuts/1kewLH-Vack/dDyuAW5_BwAJ

My feeling is that the bug is on Go's side, because quotation marks are not required by the HTML5 spec.

Yes this is a bug on Go's side, as quotation marks are not at all required by the HTML5 specification. You can mitigate this by turning on the KeepQuotes option.

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.