| .. | ||
| one-off | ||
| backfill-convex-manuals-tenant.ts | ||
| build-manuals-qdrant-corpus.ts | ||
| check-convex-manuals-gate.mjs | ||
| check-public-copy.mjs | ||
| deploy-readiness.mjs | ||
| evaluate-manuals-qdrant-corpus.ts | ||
| generate-internal-links.js | ||
| import-ghl-contacts-to-contact-profiles.ts | ||
| lighthouse-test.js | ||
| README.md | ||
| seo-internal-link-tool.js | ||
| staging-smoke.mjs | ||
| sync-manuals-to-convex.ts | ||
| sync-manuals-to-public.js | ||
| sync-thumbnails-to-public.js | ||
| sync-to-r2.sh | ||
| upload-to-r2.js | ||
SEO Internal Link Tool
A comprehensive SEO tool for Next.js applications that analyzes, optimizes, and reports on internal linking and SEO performance.
Features
- Page Discovery: Automatically discovers React pages in the
appdirectory - Sitemap Generation: Creates XML sitemaps for search engines
- Internal Link Analysis: Analyzes existing internal links and identifies issues
- Link Optimization: Automatically optimizes internal links based on SEO rules
- JSON-LD Structured Data: Generates structured data for better search visibility
- SEO Reports: Generates comprehensive SEO reports with scoring
- Interactive Mode: Command-line interactive interface
Installation
The tool is included with the project. No additional installation required.
Usage
Command Line Interface
# Generate sitemap
node scripts/seo-internal-link-tool.js sitemap --output artifacts/reports/sitemap.xml
# Analyze internal links
node scripts/internal-link-tool.js analyze --output artifacts/reports/report.json
# Optimize internal links
node scripts/seo-internal-link-tool.js optimize --output artifacts/reports/optimization.json
# Generate JSON-LD structured data
node scripts/seo-internal-link-tool.js json-ld --output artifacts/reports/json-ld-data.json
# Generate SEO report
node scripts/seo-internal-link-tool.js report --format json --output artifacts/reports/seo-report.json
# Start interactive mode
node scripts/seo-internal-link-tool.js interactive
pnpm Scripts
The tool can also be run using pnpm scripts:
# Generate sitemap
pnpm seo:sitemap -- --output artifacts/reports/sitemap.xml
# Analyze internal links
pnpm seo:analyze -- --output artifacts/reports/report.json
# Generate SEO report
pnpm seo:report -- --format json --output artifacts/reports/seo-report.json
# Generate JSON-LD structured data
pnpm seo:json-ld -- --output artifacts/reports/json-ld-data.json
Commands
sitemap
Generates an XML sitemap from React pages.
node scripts/seo-internal-link-tool.js sitemap [--output artifacts/reports/sitemap.xml]
analyze
Analyzes internal links and identifies issues like orphaned pages and broken links.
node scripts/seo-internal-link-tool.js analyze [--output artifacts/reports/report.json] [--format json|html|csv|markdown]
optimize
Optimizes internal links based on predefined rules and keywords.
node scripts/seo-internal-link-tool.js optimize [--output artifacts/reports/optimization.json]
json-ld
Generates JSON-LD structured data for better search engine visibility.
node scripts/seo-internal-link-tool.js json-ld [--output artifacts/reports/json-ld-data.json]
report
Generates a comprehensive SEO report with scoring.
node scripts/seo-internal-link-tool.js report [--output artifacts/reports/seo-report.json] [--format json|markdown|html]
interactive
Starts an interactive command-line interface.
node scripts/seo-internal-link-tool.js interactive
Configuration
The tool uses a configuration system defined in lib/internal-link-config.js which includes:
- Business Information: Company name and website URL
- Priority Links: Pages that should be prioritized for internal linking
- Keyword Mappings: Automatic linking of specific keywords to target pages
- Page-specific Rules: Configuration for different types of pages
- Link Density Rules: Limits and guidelines for link placement
- SEO Scoring Weights: How different SEO factors contribute to overall scores
Output Formats
JSON
Machine-readable format for programmatic analysis.
Markdown
Human-readable format for documentation and reports.
HTML
Interactive reports with styling for web viewing.
CSV
Tabular format for spreadsheet analysis.
Example Output
Sitemap Generation
==================================================
Generating Sitemap from React Pages
==================================================
✓ Found 37 pages
✓ Sitemap saved to: sitemap.xml
✓ Default sitemap location: /out/sitemap.xml
Link Analysis
==================================================
Analyzing Internal Links
==================================================
📊 Link Analysis Summary
Total Pages: 37
Internal Links: 7
Average Link Density: 7.00 links per page
⚠ Orphaned Pages: 36
- about-us/
- contact-us/
- services/
- etc.
SEO Report
==================================================
Generating SEO Report
==================================================
📊 SEO Analysis Summary
Total Pages Analyzed: 37
Average SEO Score: 0.5/100
🏆 Top Performing Pages:
1. services/parts/ - Score: 0.7
2. manuals/ - Score: 0.7
3. about-us/ - Score: 0.6
File Structure
scripts/
├── seo-internal-link-tool.js # Main CLI tool
├── lighthouse-test.js # Performance testing (existing)
└── generate-internal-links.js # Link generation (existing)
lib/
├── seo-utils.js # Page discovery and analysis
└── internal-link-config.js # SEO configuration
public/
└── json-ld/ # Generated JSON-LD files
Integration
The tool is designed to integrate seamlessly with existing Next.js workflows:
- Discovery: Automatically finds pages in the
appdirectory - Analysis: Works with existing React components
- Output: Generates files under
artifacts/reports/to keep the repo root clean - Configuration: Customizable through the config system
Troubleshooting
Common Issues
- Module not found: Ensure all files are in the correct location
- Permission denied: Check file permissions for output directories
- Empty results: Verify the
appdirectory contains page components
Debug Mode
Use the --verbose flag for detailed output:
node scripts/seo-internal-link-tool.js sitemap --verbose
Contributing
The tool is designed to be extensible. Key areas for enhancement:
- Additional SEO Metrics: Expand the scoring system
- Custom Rules: Add support for custom link optimization rules
- Integration: Add support for other frameworks and platforms
- Reporting: Extend the reporting system with more visualizations