vuejs / vuepress

📝 Minimalistic Vue-powered static site generator
https://vuepress.vuejs.org
MIT License
22.43k stars 4.79k forks source link

Let @vuepress/plugin-google-analytics write in <head> to support Google SearchConsole? #2766

Open luigiwerzowa opened 3 years ago

luigiwerzowa commented 3 years ago

The Google Analytics plugin works fine for Google Analytics, however, Google SearchConsole validation via Google Analytics requires the analytics.js to be in <head> rather than the <body (see official documentation). Since the latter is currently the case for the google-analytics plugin, SearchConsole validation fails.

Is there any way to get the plugin to put the analytics.js in <head>? It seems I do not understand how exactly the plugin is added to the position it is added to. In app.js I see that it is added via o.parentNode.insertBefore(s, o) but where the parameters come from is unclear to me.

Thanks in advance.

luigiwerzowa commented 3 years ago

In case this may be an issue for anyone else: You can also verify with a google-site-verification meta tag. In "a curated list of awesome things related to VuePress", at least one project uses this method: archcheatsheet.