Enabling indexing with X-Robots-Tag
Hello!
I have encountered a strange problem - my Nuxt site using nuxtjs/seo is blocking indexing on development/production with X-Robots-Tag header sent when loading the page. Could anyone help?
This is a HTTP response in browser
Project:
https://github.com/not-byte/nuxt-template
For anyone seeking into this problem - thanks a lot!
GitHub
GitHub - not-byte/nuxt-template
Contribute to not-byte/nuxt-template development by creating an account on GitHub.
23 Replies
Hi @botprzemek. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
I understand you're encountering an issue with your Nuxt site where the
X-Robots-Tag: noindex
header is being sent in both development and production environments, potentially preventing search engines from indexing your site.
Looking at the knowledge sources provided, I don't see specific information about the nuxtjs/seo
module and its interaction with the X-Robots-Tag
header. However, I can provide some insights based on the available information.
From the documentation, I can see that Nuxt has built-in SEO capabilities and also supports robots meta tags. The issue you're experiencing might be related to one of these configurations:
1. Check your SEO meta settings: You might have a robots
meta tag set to noindex
somewhere in your code. This could be in a useSeoMeta
or useServerSeoMeta
call.
Look for such configurations in your app.vue or layout files Docs > Api > Composables > useSeoMeta.
2. Check your public/robots.txt file: If you have a robots.txt file in your public directory, make sure it's not blocking indexing Docs > Guide > Directory-structure > public.
3. Check your Nuxt configuration: In your nuxt.config.ts file, look for any head meta tags related to robots or any experimental features that might affect this behavior.
4. Check for route rules: You might have route rules that set robots
to noindex
for certain routes or globally.
If you're using the nuxtjs/seo
module specifically (which isn't covered in the provided knowledge sources), you might want to check its configuration in your nuxt.config.ts file.
For a temporary workaround, you could try using the experimental respectNoSSRHeader
feature to control SSR responses Docs > Guide > Going-further > Experimental Features, though this is more related to SSR than SEO specifically.
Without more specific information about your configuration, it's difficult to pinpoint the exact cause. I recommend reviewing all SEO-related configurations in your project and ensuring none of them are setting noindex
directives.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@307600657345675265> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
@kapa.ai My useSeoMeta are set like this
const robots = (): string =>
"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1";
Let me check the knowledge base for you again. One moment! :books:
----------------------
I see you're using the
useSeoMeta
composable with a computed getter syntax for the robots meta tag. The way you've set it up should actually be allowing indexing with index, follow
directives, which is the opposite of what you're experiencing with the X-Robots-Tag: noindex
header.
However, there's a small issue with your implementation. According to the documentation, when using the computed getter syntax with useSeoMeta
, you should omit the property name in the function declaration. The correct format would be:
Notice that in your code, you're defining a separate function with const robots = (): string =>
which isn't directly connected to the useSeoMeta
call. Make sure you're actually passing this function to the useSeoMeta
composable.
Additionally, the X-Robots-Tag
HTTP header might be set elsewhere in your application. You should check:
1. Any server middleware that might be setting response headers
2. Nitro plugins that might be modifying the HTML response
3. Your nuxt.config.ts
file for any head configurations with robots directives
You could also try explicitly setting the response header to allow indexing using the useResponseHeader
composable in your app.vue or a middleware file:
This should override any existing X-Robots-Tag
header Docs > Api > Composables > useResponseHeader.
If you're still facing issues, you might want to check if there are any Nitro plugins that are hooking into the render:html
or render:response
hooks and modifying the response headers Docs > Getting-started > Views.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@307600657345675265> Kapa.ai is still learning and improving, please let me know how I did by reacting below.

useReponseHeader correctly says noindex, nofollow
most likely nuxt seo thinks the environment is not a production environment
do you have a live example?
Yeah, deployed it right now
https://nuxt.notbyte.com/
notbyte
NuxtJS template · notbyte
Discover our template for NuxtJS - an open source framework that makes web development intuitive and powerful. Create performant and production-grade full-stack web apps and websites with confidence.
Can you share the site config
Or nuxt config
You're doing something quite wrong sitemap path is pointed at local host
So likely the entire app thinks it's development
What's your build command in package.json
I'd suggest setting site config per the docs also
Just wondering, do env variables load in production ex. in docker-compose environment?
Possibly the node env is development when you're building
Depends how it's distributed
Following documentation https://nuxtseo.com/docs/site-config/guides/i18n I had created this, is it enough? Keys name, description, baseUrl and currentLocale
Nuxt SEO
Nuxt I18n · Nuxt Site Config · Nuxt SEO
How to use the Nuxt Site Config module with Nuxt I18n.


Oh ye this should be fine
For better understanding, I need to provide environment variables within building stage
It should be fine as default values are correct, absolute url pointing to the domain
Sitemap and robots are pointing to localhost
https://nuxt.notbyte.com/robots.txt
https://nuxt.notbyte.com/sitemap_index.xml
yes i think the issue is that these files may be getting generated at build-time?
although the server response time is super slow for them being static
it points to localhost when it detects a development environment
I have managed to reproduce the error,
It seems that after setting buildAssetsDir to something other than default value SEO engine creates wrong paths.
Should I create issue on GitHub?
@harlan
that would be helpful, thanks
Thanks for helping, left the issue on gh :nuxt:
@kapa.ai close the discussion
Let me check the knowledge base for you again. One moment! :books:
----------------------
I'll close this discussion about the
X-Robots-Tag
indexing issue in your Nuxt application.
To summarize what we've covered:
1. You're experiencing an issue where your Nuxt site is sending an X-Robots-Tag: noindex
header despite having configured robots: "index, follow..."
in your SEO settings
2. I suggested checking your implementation of useSeoMeta
to ensure it's properly connected to your application
3. I recommended using the useResponseHeader
composable to explicitly override the header
4. I advised checking for any server middleware or Nitro plugins that might be modifying response headers
If you need further assistance with this or any other Nuxt-related issues in the future, feel free to start a new discussion. Thank you for your questions!
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@307600657345675265> Kapa.ai is still learning and improving, please let me know how I did by reacting below.