Skip to content

Commit 10c8227

Browse files
authored
fix(gatsby): Reorder head tags (#34030)
* group head tags and reorder and spread * move tag ordering to static-entry * change reduce to sort * comment purpose of headComponents sort
1 parent d163724 commit 10c8227

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

packages/gatsby/cache-dir/static-entry.js

+10
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,16 @@ export default async function staticPage({
443443

444444
postBodyComponents.push(...bodyScripts)
445445

446+
// Reorder headComponents so meta tags are always at the top and aren't missed by crawlers
447+
// by being pushed down by large inline styles, etc.
448+
// https://github.com/gatsbyjs/gatsby/issues/22206
449+
headComponents.sort((a, b) => {
450+
if (a.type && a.type === `meta`) {
451+
return -1
452+
}
453+
return 0
454+
})
455+
446456
apiRunner(`onPreRenderHTML`, {
447457
getHeadComponents,
448458
replaceHeadComponents,

0 commit comments

Comments
 (0)