0

For my Vue SPA for which SEO is important; I have written my own function for setting meta tags per route I fire a simple function like this in the created lifecycle hook of my views:

document
    .querySelector('meta[name="robots"]')
    .setAttribute('content', 'index');

The function seems to work, because when inspecting I see the pages that need to be blocked with a noindex value and the pages that need to be indexed with an index value.

But Google search console tells me certain pages are not indexed due to the robots meta tag having the value noindex (contrary to what I expect and see when inspecting).

Is this an issue with timing and the created lifecycle hook maybe?

One of the pages where this issue occurs for extra context: https://trainervinden.nl/blog/afvallen-met-een-personal-trainer

Any help is much appreciated!

Rogier
  • 142
  • 11
  • 1
    Look at your page in google cache, you will see that the tag looks like ``. Use the Prerender SPA plugin, it should help. – Aleksandr Rogonov Mar 16 '21 at 22:24
  • Thanks for your answer Aleksandr! It sounds like quite te rewrite to go and use a prerender plugin though... I am thinking if I could switch to nuxt with similar efforts. Also thinking if there are easier solutions. But probably no short cuts :( – Rogier Mar 17 '21 at 09:58
  • 1
    1. Setting up the Prerender SPA plugin is much easier than switching to Nuxt. 2. There is another good option - to use Netlify, there is a "Prerendering" option right in the settings (and a bunch of cool things in the form of optimizing and minifying JS, CSS). And it's free and does not require any additional action from you - they will automatically take data from the repository after each commit. Just sign up there, connect the repository, redirect your domain and enjoy. – Aleksandr Rogonov Mar 17 '21 at 13:10
  • Wow thanks for your answers! I will certainly check out my options! Cheers Aleksandr! – Rogier Mar 18 '21 at 12:49

0 Answers0