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>
280 lines
8.8 KiB
Markdown
280 lines
8.8 KiB
Markdown
# 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
|
|
|
|
1. [Environment Variables](#environment-variables)
|
|
2. [Google Search Console Setup](#google-search-console-setup)
|
|
3. [Service Account Creation](#service-account-creation)
|
|
4. [API Integration](#api-integration)
|
|
5. [Testing](#testing)
|
|
6. [Deployment Checklist](#deployment-checklist)
|
|
|
|
## Environment Variables
|
|
|
|
Create a `.env.local` file in the `code/` directory with the following variables:
|
|
|
|
```bash
|
|
# 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
|
|
|
|
1. Go to [Google Search Console](https://search.google.com/search-console)
|
|
2. Click "Add Property"
|
|
3. Select "URL prefix" and enter: `https://rockymountainvending.com`
|
|
4. Choose a verification method:
|
|
- **HTML tag method**: Add the verification meta tag to `code/app/layout.tsx` in the `metadata.verification.google` field
|
|
- Uncomment the `google` line in the verification object
|
|
- Add your verification code: `google: "your-verification-code-here"`
|
|
- Or set `GOOGLE_SITE_VERIFICATION` environment variable
|
|
- **HTML file method**: Upload the provided HTML file to your site root
|
|
- **DNS method**: Add a TXT record to your domain's DNS settings
|
|
|
|
### Step 2: Submit Sitemap (Manual - Initial Setup)
|
|
|
|
1. In Google Search Console, go to "Sitemaps" in the left sidebar
|
|
2. Enter `sitemap.xml` in the "Add a new sitemap" field
|
|
3. Click "Submit"
|
|
4. Wait for Google to process the sitemap (usually within a few hours)
|
|
|
|
## Service Account Creation
|
|
|
|
### Step 1: Create Google Cloud Project
|
|
|
|
1. Go to [Google Cloud Console](https://console.cloud.google.com)
|
|
2. Create a new project or select an existing one
|
|
3. Note your project ID
|
|
|
|
### Step 2: Enable Search Console API
|
|
|
|
1. In Google Cloud Console, go to "APIs & Services" > "Library"
|
|
2. Search for "Google Search Console API"
|
|
3. Click "Enable"
|
|
|
|
### Step 3: Create Service Account
|
|
|
|
1. Go to "APIs & Services" > "Credentials"
|
|
2. Click "Create Credentials" > "Service Account"
|
|
3. Fill in:
|
|
- **Service account name**: `search-console-api`
|
|
- **Service account ID**: (auto-generated)
|
|
- **Description**: `Service account for Search Console API access`
|
|
4. Click "Create and Continue"
|
|
5. Skip role assignment (click "Continue")
|
|
6. Click "Done"
|
|
|
|
### Step 4: Generate JSON Key
|
|
|
|
1. Click on the created service account
|
|
2. Go to the "Keys" tab
|
|
3. Click "Add Key" > "Create new key"
|
|
4. Select "JSON" format
|
|
5. Click "Create" - the JSON file will download automatically
|
|
6. **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 as `GOOGLE_SERVICE_ACCOUNT_EMAIL`
|
|
- `private_key` → Use as `GOOGLE_PRIVATE_KEY` (keep the newlines as `\n`)
|
|
|
|
### Step 6: Grant Access in Search Console
|
|
|
|
1. Go back to [Google Search Console](https://search.google.com/search-console)
|
|
2. Select your property (`https://rockymountainvending.com`)
|
|
3. Go to "Settings" > "Users and permissions"
|
|
4. Click "Add user"
|
|
5. Enter the service account email (from Step 4)
|
|
6. Select "Full" permission
|
|
7. 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:
|
|
|
|
```bash
|
|
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.ts`
|
|
- `code/app/api/request-indexing/route.ts`
|
|
|
|
### Automated Sitemap Submission
|
|
|
|
Once the API is fully configured, you can:
|
|
|
|
1. **On Build/Deploy**: Automatically submit sitemap after successful deployment
|
|
2. **Via API Endpoint**: Call `/api/sitemap-submit` programmatically
|
|
3. **Via Cron Job**: Set up a scheduled task to submit sitemap periodically
|
|
|
|
Example API call:
|
|
|
|
```bash
|
|
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
|
|
|
|
1. Go to [Google Rich Results Test](https://search.google.com/test/rich-results)
|
|
2. Enter your homepage URL: `https://rockymountainvending.com`
|
|
3. Click "Test URL"
|
|
4. Verify that LocalBusiness structured data is detected
|
|
|
|
### 4. Test NAP Consistency
|
|
|
|
1. Check that phone number `(435) 233-9668` appears consistently across:
|
|
- Footer
|
|
- Header
|
|
- Contact section
|
|
- Structured data
|
|
2. Verify email `info@rockymountainvending.com` is consistent
|
|
3. Check website URL is `https://rockymountainvending.com` everywhere
|
|
|
|
### 5. Test Google Search Console API
|
|
|
|
```bash
|
|
# 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](https://developers.facebook.com/tools/debug/))
|
|
- [ ] Twitter Card tags are working (test with [Twitter Card Validator](https://cards-dev.twitter.com/validator))
|
|
- [ ] All service areas are listed correctly
|
|
- [ ] Business hours are accurate
|
|
|
|
## Post-Deployment
|
|
|
|
### Immediate Actions
|
|
|
|
1. Submit sitemap manually in Google Search Console (if not automated)
|
|
2. Request indexing for homepage: Use "URL Inspection" tool in Search Console
|
|
3. Monitor Search Console for any errors or warnings
|
|
|
|
### Ongoing Maintenance
|
|
|
|
1. **Weekly**: Check Google Search Console for:
|
|
- Coverage issues
|
|
- Indexing errors
|
|
- Mobile usability issues
|
|
- Core Web Vitals
|
|
|
|
2. **Monthly**:
|
|
- Review search performance
|
|
- Update sitemap if new pages are added
|
|
- Verify NAP consistency
|
|
|
|
3. **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.ts` exists
|
|
- Check Next.js build output for sitemap generation
|
|
- Ensure production URL is correct
|
|
|
|
### Structured Data Errors
|
|
|
|
- Use [Google Rich Results Test](https://search.google.com/test/rich-results) 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.ts` as single source of truth
|
|
- Use `NAPData` component for consistent display
|
|
- Check all hardcoded instances
|
|
|
|
## Additional Resources
|
|
|
|
- [Google Search Console Help](https://support.google.com/webmasters)
|
|
- [Schema.org LocalBusiness](https://schema.org/LocalBusiness)
|
|
- [Next.js Metadata API](https://nextjs.org/docs/app/api-reference/functions/generate-metadata)
|
|
- [Google Search Console API Documentation](https://developers.google.com/webmaster-tools/search-console-api-original)
|
|
|
|
## Support
|
|
|
|
For issues or questions:
|
|
- Check the troubleshooting section above
|
|
- Review Google Search Console documentation
|
|
- Contact your development team
|
|
|