0

All my pages are working with getStaticProps. I want to make "If there's and q parameter on URL, then add 'noindex' to ". But as you can understand, that doesnt work on 'prerendered' pages.

But I have to find a way.

I need to add 'noindex' to all my 'shop?q=blabla' pages.

On _app.js I did like that:

function MyApp({ Component, pageProps }) {
  const router = useRouter()
  ...
  
  return (
    <Fragment>
      <Head>
      ...
        {router.query.q ? <meta name="robots" content="noindex"></meta> : '' } 
      ...

But not working on getStaticProps pages. Is there any advice about it?

How can I automatically add 'noindex' to all of the 'q' parametered pages?

1 Answer 1

1

You'd need to create two different pages. One for the basic non query routing and the other for dynamic routing and use getStaticPaths for the latter.

nextjs documentation

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.