Search code examples
next.jsgoogle-search-consolecanonical-link

NextJS website index page. How to approach rel=canonical?


I have this website https://www.buscamusicos.net. Google has "/" page indexed, and I accidentally added /index to the sitemap.xml, so now Google Search Console is telling me that /index is a duplicate of /, and that I haven't set a canonical URL.

For now I've removed /index from the sitemap.xml, but I'm dubious about how to actually proceed. Should I add it again and add this to my index.js file?

<Head>
    <link
        rel="canonical"
        href="https://www.buscamusicos.net/index"
        key="canonical"
    />
</Head>

Or should I just forget about it?

Another issue is that currently the index page title is shown as BuscaMúsicos: Inicio, instead of what I set (Inicio - BuscaMúsicos). I wonder if adding the above code would make Google show the title I want.


Solution

  • If you have removed /index from your sitemap.xml and it is not linked anywhere else on your website, then there is no need to worry about it as Googlebot will not be able to crawl it and it will eventually drop out of the search results.

    I would recommend you stick with the root directory (/). You should set up a canonical URL to indicate to search engines that the content on the /index page is duplicate content of the root directory. In this case the code should look like this:

    <Head>
      <link rel="canonical" href="https://www.buscamusicos.net/" />
    </Head>
    

    Another issue is that currently the index page title is shown as BuscaMúsicos: Inicio, instead of what I set (Inicio - BuscaMúsicos). I wonder if adding the above code would make Google show the title I want.

    Make sure your title looks like this and should be reflected in the search results once Google recrawls and reindexes your page.

    <Head>
      <title>Inicio - BuscaMúsicos</title>
    </Head>