Skip to content

Latest commit

 

History

History
151 lines (107 loc) · 3.92 KB

File metadata and controls

151 lines (107 loc) · 3.92 KB

Canonical URL and Robots.txt Alignment

Overview

All SEO elements (canonical URLs, sitemap, robots.txt) now use a single, consistent domain format.

Canonical Domain

https://allphaseconstructionfl.com

Note: No www subdomain

Canonical URL Logic

Implementation

File: src/components/CanonicalManager.tsx

const origin = "https://allphaseconstructionfl.com";
const pathname = location.pathname || "/";

// Root path includes trailing slash
const canonicalUrl = pathname === "/"
  ? `${origin}/`
  : `${origin}${pathname}`;

URL Format Examples

Route Path Canonical URL
/ https://allphaseconstructionfl.com/
/residential-roofing https://allphaseconstructionfl.com/residential-roofing
/contact https://allphaseconstructionfl.com/contact
/roofing-contractor-boca-raton-fl https://allphaseconstructionfl.com/roofing-contractor-boca-raton-fl

Trailing Slash Rules

Root path (/): Has trailing slash ✅ All other paths: No trailing slash ✅ Consistent: Matches sitemap.xml exactly

Robots.txt

File: public/robots.txt

# Allow all crawlers
User-agent: *
Allow: /

# Allow specific crawlers
User-agent: Googlebot
Allow: /

User-agent: Bingbot
Allow: /

User-agent: Slurp
Allow: /

# Disallow admin pages
User-agent: *
Disallow: /admin

# Sitemap location
Sitemap: https://allphaseconstructionfl.com/sitemap.xml

Key Points

✅ Allows all search engines ✅ Blocks /admin path (not in sitemap) ✅ References canonical sitemap URL ✅ No www subdomain in sitemap reference

Alignment Verification

Domain Consistency

Element Domain
Canonical URLs https://allphaseconstructionfl.com
Sitemap XML https://allphaseconstructionfl.com
Robots.txt Sitemap https://allphaseconstructionfl.com

All elements use the same domain (no www)

Path Consistency

Sample verification showing canonical URLs match sitemap:

# Sitemap URLs
https://allphaseconstructionfl.com/
https://allphaseconstructionfl.com/residential-roofing
https://allphaseconstructionfl.com/commercial-roofing

# Canonical URLs (generated by CanonicalManager)
https://allphaseconstructionfl.com/
https://allphaseconstructionfl.com/residential-roofing
https://allphaseconstructionfl.com/commercial-roofing

Perfect match - No discrepancies

SEO Benefits

  1. No www/non-www Conflicts: Single domain format prevents duplicate content issues
  2. Consistent Canonicals: Search engines see clear, consistent signals
  3. Proper Sitemap Reference: Robots.txt points to the correct sitemap URL
  4. Trailing Slash Consistency: Predictable URL structure throughout site
  5. Single Source of Truth: All SEO elements derive from sheetSitemap.ts

Changes Made

Modified Files

  1. src/components/CanonicalManager.tsx
    • Changed domain from https://www.allphaseconstructionfl.com to https://allphaseconstructionfl.com
    • Removed www subdomain
    • Maintains trailing slash logic (root only)

Verified Files

  1. public/robots.txt

    • Already using correct domain (no changes needed)
    • Sitemap reference correct: https://allphaseconstructionfl.com/sitemap.xml
  2. public/sitemap.xml

    • Already using correct domain
    • All 64 URLs use https://allphaseconstructionfl.com

Testing Checklist

✅ Build completes successfully ✅ Canonical URLs use correct domain (no www) ✅ Root path has trailing slash ✅ Other paths have no trailing slash ✅ Robots.txt references correct sitemap URL ✅ Sitemap URLs match canonical URL format ✅ No visual or behavioral changes to site

Related Files

  • src/components/CanonicalManager.tsx - Canonical URL generation
  • public/robots.txt - Search engine directives
  • public/sitemap.xml - Generated from sheetSitemap.ts
  • src/data/sheetSitemap.ts - Single source of truth for all URLs