feat: Add environment-controlled SEO indexing #257
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.