#random noindex in production build
1 messages · Page 1 of 1 (latest)
Hi @tall gust. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
Based on the information provided in the extracts, it seems like you're encountering an issue where the noindex value is being added to the robots meta tag in the production build of your Next.js application. This issue has been reported by other users as well, particularly when using the useSearchParams hook.
A few workarounds have been suggested in the discussion:
- One user suggested removing the use of
useSearchParamsand usingwindow.location.searchwithURLSearchParamsinstead. Here's a simplified example of how you might do this:
const searchParams = new URLSearchParams(
typeof window !== 'undefined' ? window.location.search : '',
);
-
Another user suggested setting the
dynamicroute config option toforce-dynamicon the pages where you useuseSearchParams(). This will make the page load dynamically for each request and the query params will be accessible to the server. However, this approach has some trade-offs, including increased server load, caching trade-offs, and potential SEO considerations. -
You could also try configuring the robots meta tag in your layout file, as suggested by another user:
import type { Metadata } from 'next'
export const metadata: Metadata = {
robots: {
index: true,
follow: true,
},
}
Please note that these are workarounds and may not completely resolve the issue. The Next.js team might be working on a fix for this, so it's a good idea to keep an eye on the Next.js GitHub repository (https://github.com/vercel/next.js/issues/58615) for updates.
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@tall gust kapa.ai is still learning and improving, please let us know how it did by reacting below
turns out that noindex appears only in view-page source page and not in devtools @charred pilot
Let me check the knowledge base for you. One moment! :books:
This behavior is actually expected and is related to how Next.js and modern web browsers work. When you view the page source, you're seeing the initial HTML that is sent from the server. However, when you inspect the page using developer tools, you're seeing the current state of the DOM, which can be modified by JavaScript after the initial page load.
In the case of Next.js, it dynamically updates the meta tags based on your configuration when the JavaScript bundle is executed in the browser. This is why you're seeing the correct robots meta tag when inspecting the page using developer tools, but not when viewing the page source.
However, it's important to note 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.
That being said, not all search engines have this capability, and relying solely on JavaScript for important SEO elements can lead to unpredictability. For optimal SEO, consistency between the initial HTML and the post-JavaScript-rendered HTML is recommended.
You can read more about this discussion in the Next.js GitHub repository (https://github.com/vercel/next.js/issues/58615).
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@tall gust kapa.ai is still learning and improving, please let us know how it did by reacting below
@charred pilot youre right but on view-page source there is still noindex for some reason
Let me check the knowledge base for you. One moment! :books:
This issue might be related to the use of useSearchParams in your Next.js application. As discussed in the Next.js GitHub repository (https://github.com/vercel/next.js/issues/58615), the use of useSearchParams is causing the addition of a noindex value in the robots meta tag in the production build.
A potential workaround suggested by users is to avoid using useSearchParams and instead use window.location.search with URLSearchParams. Here's a simplified example:
const searchParams = new URLSearchParams(
typeof window !== 'undefined' ? window.location.search : '',
);
Another suggestion is to explicitly set the robots meta tag in your layout file:
import type { Metadata } from 'next'
export const metadata: Metadata = {
robots: {
index: true,
follow: true,
},
}
Please note that these are workarounds and may not completely resolve the issue. The Next.js team might be working on a fix for this, so it's a good idea to keep an eye on the Next.js GitHub repository (https://github.com/vercel/next.js/issues/58615) for updates.
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@tall gust kapa.ai is still learning and improving, please let us know how it did by reacting below
@charred pilot feels like build im making on the server is different with one that i make locally. is it possible that something cached and what should i do
Let me check the knowledge base for you. One moment! :books:
Yes, it's possible that the differences you're seeing between your local and server builds are due to caching. Next.js uses a cache to improve build performance, which is saved to .next/cache and shared between builds. This cache can affect the output of your builds, especially if it becomes stale or out of sync.
Here are a few things you can do:
-
Clear the Next.js cache: You can manually clear the Next.js cache by deleting the
.next/cachedirectory in your project. This will force Next.js to create a new cache the next time you run a build. -
Configure your CI/CD to persist the cache: If you're using a Continuous Integration (CI) environment for your builds, you'll need to configure it to correctly persist the cache between builds. If your CI is not configured to persist
.next/cachebetween builds, you may see a No Cache Detected (https://nextjs.org/docs/messages/no-cache) error. The Next.js documentation (https://nextjs.org/docs/pages/building-your-application/deploying/ci-build-caching) provides example cache configurations for common CI providers. -
Check for differences in environment variables: Differences in environment variables between your local and server environments can also cause differences in builds. Make sure that all necessary environment variables are correctly set in both environments.
Remember, these are general suggestions and the exact solution may depend on your specific situation and setup. If you're still having issues, it might be helpful to provide more details about your build process and environment.
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@tall gust kapa.ai is still learning and improving, please let us know how it did by reacting below
@charred pilot i think i found the problem. i have root layout on top of the app and layout under (main) folder. seems like everything that inside this folder is not extends root layout for some reason
Let me check the knowledge base for you. One moment! :books:
Based on the information provided in the extracts, it seems like you're encountering an issue where the root layout is not being applied to the sub page layouts. This issue has been reported by other users as well, particularly when using Redux context in the root layout.
As per the Next.js documentation (https://nextjs.org/docs/app/api-reference/file-conventions/layout#root-layouts), the app directory must include a root app/layout.js and the root layout must define <html> and <body> tags.
However, if you're using Redux context in your root layout and you have sub page layouts, you might encounter issues. One user reported that the Redux context that is applied in the root layout was not being applied to all sub page layouts.
A potential workaround suggested by users is to wrap the Redux context around the page layouts. However, this might not completely resolve the issue and you might need to add a second provider in your sub page layout.
Please note that these are workarounds and may not completely resolve the issue. The Next.js team might be working on a fix for this, so it's a good idea to keep an eye on the Next.js GitHub repository (https://github.com/vercel/next.js/issues/49557) for updates.
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@tall gust kapa.ai is still learning and improving, please let us know how it did by reacting below
at the build time it says that my whole page turned into client side page, why is it hapenning?
import { Card } from '@/system/ui/card'
import { Metadata } from 'next'
import { Text } from '@/system/ui/text'
import ProfilesSearchContainer from '@/components/Main/ProfilesSearch/ProfilesSearchContainer'
import { FaBalanceScaleRight } from 'react-icons/fa'
import { Badge } from '@/system/ui/badge'
export const metadata: Metadata = {
title: 'Поиск юристов для бесплатной консультации онлайн — LEXARO',
description:
'Проконсультируйтесь с лучшими юристами онлайн бесплатно. Удобный поиск юристов на Lexaro. Лучшие юристы вашего города.',
openGraph: {
title: 'Поиск юристов для бесплатной консультации онлайн — LEXARO',
description:
'Проконсультируйтесь с лучшими юристами онлайн бесплатно. Удобный поиск юристов на Lexaro. Лучшие юристы вашего города.',
type: 'website',
locale: 'ru-RU',
},
}
export default function SearchPage() {
return (
<div className="flex flex-col gap-y-20">
<Card
variant="solid"
className="flex px-10 py-8 overflow-hidden relative items-center justify-center text-center bg-gradient-to-r from-zinc-50 to-zinc-100"
>
<div className="flex flex-col gap-y-4 items-center justify-center z-10">
<Badge className="bg-lime-400 text-zinc-900 text-xs">
КРУПНЕЙШНАЯ ЮРИДИЧЕСКАЯ БАЗА
</Badge>
<Text className="text-2xl lg:text-4xl font-bold">Поиск юристов</Text>
<Text size="sm" color="600" className="max-w-4xl">
Найдите своего идеального юриста с нашим сервисом! Просто опишите вашу
проблему, используя удобный
@charred pilot at the build time it says that my whole page turned into client side page, why is it hapenning?
import { Card } from '@/system/ui/card'
import { Metadata } from 'next'
import { Text } from '@/system/ui/text'
import ProfilesSearchContainer from '@/components/Main/ProfilesSearch/ProfilesSearchContainer'
import { FaBalanceScaleRight } from 'react-icons/fa'
import { Badge } from '@/system/ui/badge'
export const metadata: Metadata = {
title: 'Поиск юристов для бесплатной консультации онлайн — LEXARO',
description:
'Проконсультируйтесь с лучшими юристами онлайн бесплатно. Удобный поиск юристов на Lexaro. Лучшие юристы вашего города.',
openGraph: {
title: 'Поиск юристов для бесплатной консультации онлайн — LEXARO',
description:
'Проконсультируйтесь с лучшими юристами онлайн бесплатно. Удобный поиск юристов на Lexaro. Лучшие юристы вашего города.',
type: 'website',
locale: 'ru-RU',
},
}
export default function SearchPage() {
return (
<div className="flex flex-col gap-y-20">
<Card
variant="solid"
className="flex px-10 py-8 overflow-hidden relative items-center justify-center text-center bg-gradient-to-r from-zinc-50 to-zinc-100"
>
<div className="flex flex-col gap-y-4 items-center justify-center z-10">
<Badge className="bg-lime-400 text-zinc-900 text-xs">
КРУПНЕЙШНАЯ ЮРИДИЧЕСКАЯ БАЗА
</Badge>
<Text className="text-2xl lg:text-4xl font-bold">Поиск юристов</Text>
<Text size="sm" color="600" className="max-w-4xl">
Найдите своего идеального юриста с нашим сервисом! Просто опишите вашу
проблему, используя удобный
Let me check the knowledge base for you. One moment! :books: