From f1fa5394954a26a67e382efb11384d1d54fb8709 Mon Sep 17 00:00:00 2001 From: Hermes Agent Date: Sat, 18 Jul 2026 17:54:13 +0000 Subject: [PATCH] SEO: comprehensive search engine optimization for bilhej.se Adds 7 SEO improvements across the full stack: 1. Enhanced index.html: - Open Graph tags (og:title, og:description, og:image, og:locale sv_SE) - Twitter Card tags (summary_large_image) - Canonical URL (https://bilhej.se/) - Meta keywords, author, robots, language tags - Structured data in JSON-LD (Organization, WebSite, Service, FAQPage) - FAQ structured data with 4 Q&A pairs (pris, anonymitet, hur funkar det) - Preconnect hints for analytics origin 2. robots.txt: - Disallow: auth pages, admin, orders, payment, guest pages - Allow: public pages (/, /om-oss, /kontakt, /integritetspolicy, /villkor) - Crawl-delay: 10s - Points to sitemap 3. sitemap.xml: - 6 public URLs with proper changefreq and priority - Home (1.0), Om (0.7), Kontakt (0.6), GDPR/Villkor (0.5) 4. useSeo composable: - Dynamic document.title, meta description/OG/Twitter on route change - Canonical URL updates per page - Reset fallback for unnamed routes 5. Route-level SEO data: - 16 routes with unique title, description, keywords - Covers all public pages + key auth pages 6. App.vue: wired useSeo with route.name watcher (immediate: true) 7. nginx.conf: - Security headers: X-Frame-Options DENY, X-Content-Type-Options, X-XSS-Protection, Referrer-Policy, Permissions-Policy, HSTS - Far-future cache (1y, immutable) for static assets - No-cache for robots.txt and sitemap.xml - Deny access to dotfiles - Stronger gzip config --- docker/nginx.conf | 49 +++++++++-- frontend/index.html | 135 ++++++++++++++++++++++++++++- frontend/public/robots.txt | 27 ++++++ frontend/public/sitemap.xml | 36 ++++++++ frontend/src/App.vue | 22 +++++ frontend/src/composables/useSeo.ts | 95 ++++++++++++++++++++ frontend/src/data/routeSeo.ts | 90 +++++++++++++++++++ 7 files changed, 447 insertions(+), 7 deletions(-) create mode 100644 frontend/public/robots.txt create mode 100644 frontend/public/sitemap.xml create mode 100644 frontend/src/composables/useSeo.ts create mode 100644 frontend/src/data/routeSeo.ts diff --git a/docker/nginx.conf b/docker/nginx.conf index db4c5f2..91dae72 100644 --- a/docker/nginx.conf +++ b/docker/nginx.conf @@ -1,7 +1,7 @@ server { listen 80; listen 443 ssl; - server_name _; + server_name bilhej.se www.bilhej.se; ssl_certificate /etc/nginx/certs/cert.crt; ssl_certificate_key /etc/nginx/certs/cert.key; @@ -11,20 +11,59 @@ server { root /usr/share/nginx/html; index index.html; + # ── Security headers ────────────────────────────────────────── + add_header X-Frame-Options "DENY" always; + add_header X-Content-Type-Options "nosniff" always; + add_header X-XSS-Protection "1; mode=block" always; + add_header Referrer-Policy "strict-origin-when-cross-origin" always; + add_header Permissions-Policy "camera=(), microphone=(), geolocation=()" always; + # Strict-Transport-Security only when HTTPS is active + add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always; + + # ── Gzip ────────────────────────────────────────────────────── + gzip on; + gzip_types text/plain text/css application/json application/javascript text/xml + application/xml text/javascript image/svg+xml text/markdown; + gzip_vary on; + gzip_min_length 256; + gzip_comp_level 6; + + # ── API reverse proxy ───────────────────────────────────────── location /api/ { proxy_pass http://backend:8080; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Forwarded-Host $host; } + # ── Static assets with far-future cache ─────────────────────── + location ~* \.(?:ico|svg|css|js|woff2?|ttf|eot|png|jpg|jpeg|gif|webp|avif)$ { + expires 1y; + add_header Cache-Control "public, immutable"; + add_header Vary "Accept-Encoding"; + try_files $uri =404; + } + + # ── Robots + sitemap (never cached, fresh every time) ───────── + location = /robots.txt { + add_header Cache-Control "no-cache, must-revalidate"; + try_files $uri =404; + } + location = /sitemap.xml { + add_header Cache-Control "no-cache, must-revalidate"; + try_files $uri =404; + } + + # ── SPA fallback — serve index.html for all other routes ────── location / { try_files $uri $uri/ /index.html; } - gzip on; - gzip_types text/plain text/css application/json application/javascript text/xml application/xml text/javascript image/svg+xml; - gzip_vary on; - gzip_min_length 256; + # ── Deny access to dotfiles ─────────────────────────────────── + location ~ /\. { + deny all; + return 404; + } } diff --git a/frontend/index.html b/frontend/index.html index a4f349f..821f2c0 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -4,12 +4,143 @@ - + + + Bilhej — Skicka brev till fordonsägare via registreringsnummer + + + + + + + + + + + + + + + + + + + + + + + + + + + + - Bilhej — Skicka brev till fordonsägare + + + + + + + + + + + +
diff --git a/frontend/public/robots.txt b/frontend/public/robots.txt new file mode 100644 index 0000000..3d9cbda --- /dev/null +++ b/frontend/public/robots.txt @@ -0,0 +1,27 @@ +# Allow all crawlers +User-agent: * +Crawl-delay: 10 +Disallow: /api/ +Disallow: /admin/ +Disallow: /orders/ +Disallow: /bestallning/*/redigera +Disallow: /betalning/* +Disallow: /gast-bestallning* +Disallow: /gast-betalning/* +Disallow: /gast-order/* +Disallow: /andra-losenord +Disallow: /andra-epost +Disallow: /bekrafta-epost +Disallow: /aterstall-losenord +Disallow: /glomt-losenord + +# Allow important pages +Allow: / +Allow: /om-oss +Allow: /om +Allow: /kontakt +Allow: /integritetspolicy +Allow: /villkor + +# Sitemap +Sitemap: https://bilhej.se/sitemap.xml diff --git a/frontend/public/sitemap.xml b/frontend/public/sitemap.xml new file mode 100644 index 0000000..a5541e5 --- /dev/null +++ b/frontend/public/sitemap.xml @@ -0,0 +1,36 @@ + + + + https://bilhej.se/ + weekly + 1.0 + + + https://bilhej.se/om-oss + monthly + 0.7 + + + https://bilhej.se/om + monthly + 0.3 + + + https://bilhej.se/kontakt + monthly + 0.6 + + + https://bilhej.se/integritetspolicy + monthly + 0.5 + + + https://bilhej.se/villkor + monthly + 0.5 + + diff --git a/frontend/src/App.vue b/frontend/src/App.vue index ddb678e..63ae1b6 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -1,7 +1,29 @@