-
Notifications
You must be signed in to change notification settings - Fork 26.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use of useSearchParams is causing the addition of meta robots with noindex in the production build #58615
Comments
@iskipu, if you use the element inspector to search for the robots meta tag, only the one I configured will appear. However, if you check the page source, you'll see that it's still there. With this, even though it's dynamically removed, it will always appear in the base HTML. And because of this, search engines might end up interpreting the noindex, since it is found in the HTML. To illustrate this better, I deployed this repository on Vercel. But just like you said, using the element inspector removes the noindex, but in the HTML, it's still there. Here's the link in case you want to check it out. Well, I believe that html being built with noindex is a problem. That's why I opened this issue. |
@FrancisGregori Afaik crawlers used by browsers use the generated DOM for SEO rather than the base HTML. Use any of the SEO tools for meta tag analysis i am using this (https://smallseotools.com/meta-tags-analyzer/) and then paste your url (https://nextjs-noindex-issue.vercel.app/) and check the report generated and you can see that the robot meta tag is (index, follow). So it might not be big issue but since it is reflecting differently in base html it is still a small issue like you said. |
I have the same issue on next.js 14.0.3. Probably the tag was added to avoid indexing of user data, but on the other hand, it prevents the indexing from Google for the whole page. Not a good way to handle it IMO. I am also looking for a solution. |
@marduc812 , as a workaround I ended up removing the use of useSearchParams and using const searchParams = new URLSearchParams(
typeof window !== 'undefined' ? window.location.search : '',
); Maybe this will help you temporarily. |
@iskipu, you're right that modern search engine crawlers, like Googlebot, are capable of processing JavaScript and can analyze the generated DOM for SEO purposes. This means they can see the page as a user would after JavaScript execution, including any changes to meta tags. However, as you pointed out, there's still a discrepancy between the base HTML and the rendered version, which can be a concern. Although advanced crawlers can interpret JavaScript, not all search engines have this capability. Plus, relying solely on JavaScript for important SEO elements can lead to unpredictability, especially if a crawler encounters issues executing the JavaScript. It's a smaller issue, but for optimal SEO, consistency between the initial HTML and the post-JavaScript-rendered HTML is recommended. |
@FrancisGregori Understood thanks for the clear explanation 😄 |
Indeed, the use of |
I had to use useSearchParams in my project as well, had the same issue of duplicated meta tag robots with noindex value, but even removing useSearchParams from a project and deleting .next folder to rebuild the app again didn't solve the issue. |
My bad, I didn't double check if I removed useSearchParams completly from my app, I found one more place where I used it, after removing it the issue with duplicated metatag gone.
Is indeed good. |
Took me a while to track down how this was being added to my build. Thanks @FrancisGregori for the clear workaround. My index page |
I know the feeling @jo-sip, it also took me a while to figure out what the problem was. And I'm glad the workaround helped you. |
"next": "14.0.3" Has removed useSearchParams in one typescript BUT not enough to fix the issue. |
@pier7529, I believe you haven't set up the robots meta tag, right? I saw that the So, I would suggest you configure the robots meta in your import type { Metadata } from 'next'
export const metadata: Metadata = {
robots: {
index: true,
follow: true,
},
} Here's a very simplified example, but you can check out other configurations here if you think it's necessary. Besides that, I would also suggest doing a double check to ensure that |
@FrancisGregori I've tried this :
In Navigator Inspector, I can see the correct values :
BUT when I display the code source of the same page, I got this (in "npm run dev" mode) :
So don't understand. |
Same issue. |
Setting the dynamic route config option to |
@haginus, using Increased Server Load: It leads to server-side rendering on every request, which can gently heighten server workload and extend response times. Caching Trade-offs: This approach bypasses some of Next.js's caching advantages, which might slightly impact site performance. SEO Considerations: While it avoids adding a noindex meta tag, there's a subtle possibility that slower load times could affect SEO, but this can be managed. In essence, |
In my context, I think I solved my issue with meta no index or multiple meta robots |
For the last 5 days I have wondered why this meta was added while everything else was working fine. This is really concerning, especially for a framework that is supposed to be SEO-friendly. Even if it's minor, it has an impact. Don't hesitate to let us know when this is fixed. In my case, I need to use the useSearchParams in some components. Thanks @FrancisGregori for raising this issue and making me feel less alone. I'm surprised that so few people are concerned |
We cannot recreate the issue with the provided information. Please add a reproduction in order for us to be able to investigate. Why was this issue marked with the
|
Hey @leerob, upon inspecting through the elements panel, everything seems to be in order. However, in this instance, we are examining the DOM which has been modified by JavaScript. If you take a look at the source code directly( |
Thank you! We have a PR going #59531. |
Awesome @leerob! Thanks for the heads up. Much appreciated! |
Any ETA on when the PR will make it to main, I am running into this issue and haven't been able to resolve it with the items suggested on this thread |
This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Link to the code that reproduces this issue
https://github.com/FrancisGregori/nextjs-noindex-issue
To Reproduce
13.5.6-canary.3
or higher.Current vs. Expected behavior
Current Behavior:
When using
useSearchParams
in Next.js version 13 or higher, the<meta name="robots" content="noindex"/>
tag is automatically added to pages in the production build. This occurs even if the robots meta tag is already configured manually, leading to erroneous addition and potential duplication of the robots meta tag.Expected Behavior:
The
<meta name="robots" content="noindex"/>
tag should only be added in preview versions, not affecting the production build. Manual configurations of the robots meta tags should be respected to avoid duplication and ensure correct indexing of pages by search engines in production.Verify canary release
Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 23.1.0: Mon Oct 9 21:27:24 PDT 2023; root:xnu-10002.41.9~6/RELEASE_ARM64_T6000 Binaries: Node: 18.17.0 npm: 9.6.7 Yarn: 1.22.19 pnpm: N/A Relevant Packages: next: 14.0.4-canary.2 eslint-config-next: 14.0.1 react: 18.2.0 react-dom: 18.2.0 typescript: 5.2.2 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
Metadata (metadata, generateMetadata, next/head), Routing (next/router, next/navigation, next/link)
Additional context
I have encountered this problem both locally and when deploying on Vercel. Upon further investigation, it seems that this issue started with version
13.5.6-canary.3
. This observation leads me to believe that the erroneous addition of the<meta name="robots" content="noindex"/>
tag in the production build when using useSearchParams might be specific to this and subsequent versions. Prior versions, including13.5.6-canary.2
and earlier, do not exhibit this issue.NEXT-1853
The text was updated successfully, but these errors were encountered: