feat: Add environment-controlled SEO indexing#257
Open
Conversation
- add SEOControl component for conditional robots meta tags - create dynamic robots.txt based on NEXT_PUBLIC_ALLOW_INDEXING - update next.config.js with new environment variables - include comprehensive documentation and examples - support for staging/production environment differentiation - compatible with Google AI Mode and modern SEO practices Environment variables: - NEXT_PUBLIC_ALLOW_INDEXING: controls indexing (default: true) - NEXT_PUBLIC_SITE_URL: site URL for robots.txt sitemap reference
✅ Deploy Preview for leafy-mooncake-7c2e5e ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR implements environment-controlled SEO indexing to prevent search engines from indexing non-production environments while allowing indexing in production through environment variable configuration.
- Adds conditional noindex meta tags based on
NEXT_PUBLIC_ALLOW_INDEXINGenvironment variable - Implements dynamic robots.txt generation that blocks or allows crawlers depending on environment
- Integrates SEO control component globally through
_app.tsx
Reviewed Changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/components/seo-control.tsx |
New component that conditionally adds noindex meta tags when indexing is disabled |
src/pages/robots.txt.tsx |
Dynamic robots.txt endpoint that generates appropriate crawler directives based on environment |
src/pages/_app.tsx |
Integrates SEO control component globally across all pages |
docs/seo-indexing-control.md |
Comprehensive documentation covering implementation, configuration, and usage |
.env.local.example |
Example environment configuration file with SEO indexing variables |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds environment-controlled SEO indexing functionality to prevent search engines from indexing development and staging environments while allowing indexing in production.
Changes
Core Implementation
Files Added/Modified
components/seo-control.tsx- New component for meta tag managementpages/robots.txt.tsx- Dynamic robots.txt endpointpages/_app.tsx- Integration of SEO control componentnext.config.js- Environment variable configuration.env.local- Local development settings (indexing disabled).env.local.example- Example environment configurationdocs/seo-indexing-control.md- Comprehensive documentationEnvironment Variables
NEXT_PUBLIC_ALLOW_INDEXING: Controls whether search engines can index the site (true/false)NEXT_PUBLIC_SITE_URL: Site URL for sitemap reference in robots.txtBehavior
When
NEXT_PUBLIC_ALLOW_INDEXING=false(Development/Staging)<meta name="robots" content="noindex, nofollow" />to all pages<meta name="googlebot" content="nosnippet" />for extra protectionDisallow: /blocking all crawlersWhen
NEXT_PUBLIC_ALLOW_INDEXING=true(Production)Testing
✅ Verified meta tags are correctly added in development
✅ Verified robots.txt responds appropriately to environment settings
✅ Confirmed environment variable control works as expected
Documentation
Added comprehensive documentation in
docs/seo-indexing-control.mdcovering:Production Deployment
For production deployment, ensure
NEXT_PUBLIC_ALLOW_INDEXING=trueis set to allow search engine indexing.