-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Add environment-controlled SEO indexing #257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pull request does not contain a valid label. Please add one of the following labels: ['release-no', 'release-auto', 'release-patch', 'release-minor', 'release-major']
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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>
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.