Next.js website for Rocky Mountain Vending company featuring: - Product catalog with Stripe integration - Service areas and parts pages - Admin dashboard with Clerk authentication - SEO optimized pages with JSON-LD structured data Co-authored-by: Cursor <cursoragent@cursor.com>
8.8 KiB
SEO and Google Search Console Setup Guide
This guide covers the complete setup process for SEO features, Google Search Console integration, and automated sitemap submission.
Table of Contents
- Environment Variables
- Google Search Console Setup
- Service Account Creation
- API Integration
- Testing
- Deployment Checklist
Environment Variables
Create a .env.local file in the code/ directory with the following variables:
# Site Configuration
NEXT_PUBLIC_SITE_URL=https://rockymountainvending.com
NEXT_PUBLIC_APP_URL=https://rockymountainvending.com
# Google Search Console API Configuration
# Required for automated sitemap submission and URL indexing
# Service Account Email (from Google Cloud Console)
GOOGLE_SERVICE_ACCOUNT_EMAIL=your-service-account@your-project.iam.gserviceaccount.com
# Private Key (from service account JSON key file)
# Note: Replace \n with actual newlines or use a single-line format
GOOGLE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\nYour-Private-Key-Here\n-----END PRIVATE KEY-----"
# Optional: Google Search Console Site URL
# Defaults to NEXT_PUBLIC_SITE_URL if not set
GOOGLE_SITE_URL=https://rockymountainvending.com
Google Search Console Setup
Step 1: Verify Site Ownership
- Go to Google Search Console
- Click "Add Property"
- Select "URL prefix" and enter:
https://rockymountainvending.com - Choose a verification method:
- HTML tag method: Add the verification meta tag to
code/app/layout.tsxin themetadata.verification.googlefield- Uncomment the
googleline in the verification object - Add your verification code:
google: "your-verification-code-here" - Or set
GOOGLE_SITE_VERIFICATIONenvironment variable
- Uncomment the
- HTML file method: Upload the provided HTML file to your site root
- DNS method: Add a TXT record to your domain's DNS settings
- HTML tag method: Add the verification meta tag to
Step 2: Submit Sitemap (Manual - Initial Setup)
- In Google Search Console, go to "Sitemaps" in the left sidebar
- Enter
sitemap.xmlin the "Add a new sitemap" field - Click "Submit"
- Wait for Google to process the sitemap (usually within a few hours)
Service Account Creation
Step 1: Create Google Cloud Project
- Go to Google Cloud Console
- Create a new project or select an existing one
- Note your project ID
Step 2: Enable Search Console API
- In Google Cloud Console, go to "APIs & Services" > "Library"
- Search for "Google Search Console API"
- Click "Enable"
Step 3: Create Service Account
- Go to "APIs & Services" > "Credentials"
- Click "Create Credentials" > "Service Account"
- Fill in:
- Service account name:
search-console-api - Service account ID: (auto-generated)
- Description:
Service account for Search Console API access
- Service account name:
- Click "Create and Continue"
- Skip role assignment (click "Continue")
- Click "Done"
Step 4: Generate JSON Key
- Click on the created service account
- Go to the "Keys" tab
- Click "Add Key" > "Create new key"
- Select "JSON" format
- Click "Create" - the JSON file will download automatically
- Important: Store this file securely and never commit it to version control
Step 5: Extract Credentials from JSON
Open the downloaded JSON file and extract:
client_email→ Use asGOOGLE_SERVICE_ACCOUNT_EMAILprivate_key→ Use asGOOGLE_PRIVATE_KEY(keep the newlines as\n)
Step 6: Grant Access in Search Console
- Go back to Google Search Console
- Select your property (
https://rockymountainvending.com) - Go to "Settings" > "Users and permissions"
- Click "Add user"
- Enter the service account email (from Step 4)
- Select "Full" permission
- Click "Add"
API Integration
Current Implementation
The API endpoints are set up at:
/api/sitemap-submit- Submit sitemap to Google Search Console/api/request-indexing- Request URL indexing
Manual API Integration (Advanced)
To enable full automated functionality, you'll need to install the Google APIs client library:
npm install googleapis
Then update the API route files to use the actual Google Search Console API. See the comments in:
code/app/api/sitemap-submit/route.tscode/app/api/request-indexing/route.ts
Automated Sitemap Submission
Once the API is fully configured, you can:
- On Build/Deploy: Automatically submit sitemap after successful deployment
- Via API Endpoint: Call
/api/sitemap-submitprogrammatically - Via Cron Job: Set up a scheduled task to submit sitemap periodically
Example API call:
curl -X POST https://rockymountainvending.com/api/sitemap-submit \
-H "Content-Type: application/json" \
-d '{"sitemapUrl": "https://rockymountainvending.com/sitemap.xml"}'
Testing
1. Verify Sitemap Accessibility
Visit: https://rockymountainvending.com/sitemap.xml
You should see a valid XML sitemap with all your pages listed.
2. Verify Robots.txt
Visit: https://rockymountainvending.com/robots.txt
You should see:
User-agent: *
Allow: /
Disallow: /api/
Disallow: /admin/
Disallow: /_next/
Sitemap: https://rockymountainvending.com/sitemap.xml
3. Test Structured Data
- Go to Google Rich Results Test
- Enter your homepage URL:
https://rockymountainvending.com - Click "Test URL"
- Verify that LocalBusiness structured data is detected
4. Test NAP Consistency
- Check that phone number
(435) 233-9668appears consistently across:- Footer
- Header
- Contact section
- Structured data
- Verify email
info@rockymountainvending.comis consistent - Check website URL is
https://rockymountainvending.comeverywhere
5. Test Google Search Console API
# Test sitemap submission endpoint
curl https://rockymountainvending.com/api/sitemap-submit
# Test indexing request endpoint
curl https://rockymountainvending.com/api/request-indexing
Deployment Checklist
Before deploying to production:
- All environment variables are set in production environment
- Google Search Console property is verified
- Service account has been granted access in Search Console
- Sitemap is accessible at
/sitemap.xml - Robots.txt is accessible at
/robots.txt - Structured data validates in Google Rich Results Test
- NAP information is consistent across all pages
- Open Graph tags are working (test with Facebook Sharing Debugger)
- Twitter Card tags are working (test with Twitter Card Validator)
- All service areas are listed correctly
- Business hours are accurate
Post-Deployment
Immediate Actions
- Submit sitemap manually in Google Search Console (if not automated)
- Request indexing for homepage: Use "URL Inspection" tool in Search Console
- Monitor Search Console for any errors or warnings
Ongoing Maintenance
-
Weekly: Check Google Search Console for:
- Coverage issues
- Indexing errors
- Mobile usability issues
- Core Web Vitals
-
Monthly:
- Review search performance
- Update sitemap if new pages are added
- Verify NAP consistency
-
Quarterly:
- Review and update structured data
- Check service areas are still accurate
- Update business hours if changed
Troubleshooting
Sitemap Not Found
- Verify
code/app/sitemap.tsexists - Check Next.js build output for sitemap generation
- Ensure production URL is correct
Structured Data Errors
- Use Google Rich Results Test to identify issues
- Check JSON-LD syntax in browser DevTools
- Verify all required fields are present
API Authentication Errors
- Verify service account email is correct
- Check private key format (newlines must be
\n) - Ensure service account has Search Console access
- Verify Search Console API is enabled in Google Cloud
NAP Inconsistencies
- Use
code/lib/seo-config.tsas single source of truth - Use
NAPDatacomponent for consistent display - Check all hardcoded instances
Additional Resources
- Google Search Console Help
- Schema.org LocalBusiness
- Next.js Metadata API
- Google Search Console API Documentation
Support
For issues or questions:
- Check the troubleshooting section above
- Review Google Search Console documentation
- Contact your development team