diff --git a/backend/app.py b/backend/app.py index ef4b7a0..260f163 100644 --- a/backend/app.py +++ b/backend/app.py @@ -584,6 +584,23 @@ async def reload_data( return {"status": "reloaded"} +# ============================================================================= +# SEO FILES +# ============================================================================= + + +@app.get("/robots.txt") +async def robots_txt(): + """Serve robots.txt for search engine crawlers.""" + return FileResponse(settings.frontend_dir / "robots.txt", media_type="text/plain") + + +@app.get("/sitemap.xml") +async def sitemap_xml(): + """Serve sitemap.xml for search engine indexing.""" + return FileResponse(settings.frontend_dir / "sitemap.xml", media_type="application/xml") + + # Mount static files directly (must be after all routes to avoid catching API calls) if settings.frontend_dir.exists(): app.mount("/static", StaticFiles(directory=settings.frontend_dir), name="static") diff --git a/frontend/app.js b/frontend/app.js index dddde62..ebf33f7 100644 --- a/frontend/app.js +++ b/frontend/app.js @@ -208,6 +208,12 @@ const routes = { "/rankings": "rankings", }; +const pageTitles = { + dashboard: "SchoolCompare | Compare Primary School Performance", + compare: "Compare Schools | SchoolCompare", + rankings: "School Rankings | SchoolCompare", +}; + function navigateTo(path) { // Update URL without reload window.history.pushState({}, "", path); @@ -218,6 +224,9 @@ function handleRoute() { const path = window.location.pathname; const view = routes[path] || "dashboard"; + // Update page title for SEO + document.title = pageTitles[view] || pageTitles.dashboard; + // Update navigation document.querySelectorAll(".nav-link").forEach((link) => { link.classList.toggle("active", link.dataset.view === view); diff --git a/frontend/index.html b/frontend/index.html index 6f9ad47..6589e66 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -4,6 +4,52 @@ SchoolCompare | Compare Primary School Performance + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/frontend/robots.txt b/frontend/robots.txt new file mode 100644 index 0000000..1acdcf6 --- /dev/null +++ b/frontend/robots.txt @@ -0,0 +1,8 @@ +User-agent: * +Allow: / +Allow: /compare +Allow: /rankings + +Disallow: /api/ + +Sitemap: https://schoolcompare.co.uk/sitemap.xml diff --git a/frontend/sitemap.xml b/frontend/sitemap.xml new file mode 100644 index 0000000..72e473d --- /dev/null +++ b/frontend/sitemap.xml @@ -0,0 +1,18 @@ + + + + https://schoolcompare.co.uk/ + weekly + 1.0 + + + https://schoolcompare.co.uk/compare + weekly + 0.8 + + + https://schoolcompare.co.uk/rankings + weekly + 0.8 + +