React-helmet: Place meta charset output at top of head

Created on 16 Feb 2017  路  5Comments  路  Source: nfl/react-helmet

According to the HTML5 specification,

The element containing the character encoding declaration must be serialized completely within the first 1024 bytes of the document.

However, as far as I can tell, react-helmet makes no attempt to output any configured <meta charset='...'> tag as the first thing in the <head> element; in fact it appears to always be output after the <title>. If other code is also writing to the <head> (e.g. styled-components), this could push the charset specification well past that 1024 byte cutoff.

Is it possible to modify the output order of the head elements produced by react-helmet?

bug

Most helpful comment

Have anyone solved this issue ?

All 5 comments

@tinynumbers on the server side, you can control the ordering of groups of head information (i.e. meta tags before title tag before link tags). And the ordering of tags should stay the same order they were given as props to Helmet. On the client, you're right, the code doesn't try to maintain this order. We can look into fixing that. Thanks!

+1 for this: I'm prerendering my page with puppeeter but title is placed below the styling thus google does not find it.

Have anyone solved this issue ?

Bump, still no solution to this issue.
Would help greatly with prerenderers such as puppeeter.

Any solution yet for this ??

Was this page helpful?
0 / 5 - 0 ratings