From 1131ca5f818f3e8be10f484183f69a24c46b8f82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20Tonh=C3=A4user?= Date: Thu, 30 Jul 2026 11:53:30 +0200 Subject: [PATCH] feat: regionale SEO-Daten zentralisieren --- public/404.html | 6 +- public/blog.html | 6 +- public/custom/seo-config.js | 62 +++++++++--- public/custom/seo.js | 23 +++-- public/datenschutz.html | 10 +- public/eventfotografie.html | 17 ++-- public/impressum.html | 8 +- public/index.html | 16 +-- public/kontakt.html | 12 +-- public/leistungen.html | 10 +- public/portfolio-abiball.html | 4 +- public/portfolio-aufstiegsfeier.html | 6 +- public/portfolio-beach-soccer-cup.html | 6 +- public/portfolio-deutschland-u21.html | 6 +- public/portfolio-fc-st-pauli.html | 6 +- public/portfolio-frauen-bundesliga.html | 6 +- public/portfolio-hamburger-sv.html | 6 +- public/portfolio-hannover-96.html | 6 +- public/portfolio-nfv-pokalfinale-2026.html | 6 +- public/portfolio-omr-yes-wecancer.html | 6 +- public/portfolio-rhine-ruhr-3x3.html | 6 +- public/portfolio-rhine-ruhr-basketball.html | 6 +- .../portfolio-rhine-ruhr-beachvolleyball.html | 6 +- public/portfolio-rhine-ruhr-sport.html | 6 +- public/portfolio-sv-meppen.html | 6 +- public/portfolio-svg-lueneburg.html | 6 +- public/portfolio-yes-con-2026.html | 6 +- public/portfolio.html | 6 +- public/über-mich.html | 12 +-- scripts/bake-seo.mjs | 46 +++++++-- scripts/check-seo.mjs | 97 +++++++++++++++++++ 31 files changed, 300 insertions(+), 131 deletions(-) create mode 100644 scripts/check-seo.mjs diff --git a/public/404.html b/public/404.html index 3309d4a..84708f2 100644 --- a/public/404.html +++ b/public/404.html @@ -3,8 +3,8 @@ - Seite nicht gefunden | Leon Tonhäuser - + 404 – Leider nichts gefunden | Leon Tonhäuser + - Blog – Leon Tonhäuser - + Blog | Leon Tonhäuser + - + diff --git a/public/custom/seo-config.js b/public/custom/seo-config.js index a119bb6..e0fc77a 100644 --- a/public/custom/seo-config.js +++ b/public/custom/seo-config.js @@ -5,28 +5,28 @@ window.SEO_CONFIG = { SITE_URL: 'https://leon-tonhaeuser.de', SITE_NAME: 'Leon Tonhäuser | Sportfotograf', - DEFAULT_DESCRIPTION: 'Sportfotograf für regionale Sportevents in Uelzen, Lüneburg und Umgebung. Rhine-Ruhr 2025, Frauen-Bundesliga und mehr im Portfolio.', + DEFAULT_DESCRIPTION: 'Sport- und Eventfotograf aus Ebstorf für Hamburg, Hannover, Wolfsburg, Uelzen, Celle, Lüneburg und deutschlandweite Events.', DEFAULT_OG_IMAGE: '/assets/portfolio/sports/rhine-ruhr/beachvolleyball/galerie-02.jpg', BUSINESS: { name: 'Leon Tonhäuser Fotografie', type: 'ProfessionalService', telephone: '+49-162-5434418', email: 'mail@leon-tonhaeuser.de', - addressLocality: 'Uelzen', + addressLocality: 'Ebstorf', addressRegion: 'Niedersachsen', addressCountry: 'DE', - areaServed: ['Uelzen', 'Lüneburg', 'Hamburg', 'Bad Bevensen', 'Winsen (Luhe)'], + areaServed: ['Hamburg', 'Hannover', 'Wolfsburg', 'Uelzen', 'Celle', 'Lüneburg'], priceRange: '€€', personName: 'Leon Tonhäuser', - personJobTitle: 'Sportfotograf', + personJobTitle: 'Sport- und Eventfotograf', defaultLocation: 'Niedersachsen', serviceType: 'Fotografie', services: ['Eventfotografie', 'Sportfotografie', 'Reportagefotografie'] }, PAGES: { '/': { - title: 'Leon Tonhäuser | Sport- & Eventfotografie aus Uelzen', - desc: 'Sportfotograf für regionale Sportevents in Uelzen, Lüneburg und Hamburg. Rhine-Ruhr 2025, Frauen-Bundesliga und mehr im Portfolio. Jetzt anfragen.', + title: 'Leon Tonhäuser | Sport- & Eventfotografie aus Ebstorf', + desc: 'Sport- und Eventfotograf aus Ebstorf, regelmäßig im Einsatz in Hamburg, Hannover und Norddeutschland. Portfolio, Leistungen und direkte Anfrage.', jsonld: ['person-business'] }, '/portfolio': { @@ -124,28 +124,62 @@ desc: 'Eventfotografie, Sportfotografie und Reportagefotografie — Leistungen für Vereine, Veranstalter und Unternehmen in Uelzen, Lüneburg und Hamburg.', jsonld: ['person-business', 'service'] }, + '/sportfotografie': { + title: 'Sportfotograf Hamburg & Norddeutschland | Leon Tonhäuser', + desc: 'Sportfotograf aus Ebstorf für Vereine, Medien und Veranstalter in Hamburg, Hannover, Wolfsburg, Uelzen, Celle und Lüneburg. Portfolio ansehen.', + jsonld: ['breadcrumb', 'person-business', 'service'], + service: { + serviceType: 'Sportfotografie', + areaServed: [ + { type: 'City', name: 'Hamburg' }, + { type: 'City', name: 'Hannover' }, + { type: 'City', name: 'Wolfsburg' }, + { type: 'City', name: 'Uelzen' }, + { type: 'City', name: 'Celle' }, + { type: 'City', name: 'Lüneburg' } + ], + services: [ + 'Spieltags- und Wettkampfreportage', + 'Turnier- und Sporteventfotografie', + 'Mannschafts- und Athletenfotografie' + ] + } + }, '/eventfotografie': { - title: 'Eventfotograf Uelzen — Firmenevents & Veranstaltungen | Leon Tonhäuser', - desc: 'Eventfotograf für Firmen in Uelzen, Lüneburg und Hamburg: Firmenveranstaltungen, Tagungen, Jubiläen und Messen — authentische Bilder für PR und Social Media.', - jsonld: ['breadcrumb', 'person-business'] + title: 'Eventfotograf Hamburg & deutschlandweit | Leon Tonhäuser', + desc: 'Eventfotograf für Firmenevents, Tagungen, Messen und Konferenzen in Hamburg und deutschlandweit. Authentische Bilder für PR, Web und Social Media.', + jsonld: ['breadcrumb', 'person-business', 'service'], + service: { + serviceType: 'Eventfotografie', + areaServed: [ + { type: 'City', name: 'Hamburg' }, + { type: 'Country', name: 'Deutschland' } + ], + services: [ + 'Firmenevent-Fotografie', + 'Tagungs- und Konferenzfotografie', + 'Messefotografie', + 'Team- und Porträtfotografie vor Ort' + ] + } }, '/über-mich': { title: 'Über mich | Leon Tonhäuser — Sportfotograf', - desc: 'Über Leon Tonhäuser: Sportfotograf aus Uelzen, tätig in Lüneburg, Hamburg und Niedersachsen. Leidenschaft für Sport, Events und Reportage.', + desc: 'Über Leon Tonhäuser: Sportfotograf aus Ebstorf, tätig in Lüneburg, Hamburg und Niedersachsen. Leidenschaft für Sport, Events und Reportage.', jsonld: ['person-business'] }, '/kontakt': { title: 'Kontakt | Leon Tonhäuser — Sportfotograf', - desc: 'Kontakt zu Leon Tonhäuser — Sportfotograf für Uelzen, Lüneburg, Hamburg. Telefon 0162-5434418, E-Mail mail@leon-tonhaeuser.de, Anfrageformular.', + desc: 'Kontakt zu Leon Tonhäuser — Sportfotograf aus Ebstorf für Hamburg, Hannover und Norddeutschland. Telefon 0162-5434418, E-Mail mail@leon-tonhaeuser.de, Anfrageformular.', jsonld: ['person-business'] }, '/datenschutz': { title: 'Datenschutzerklärung | Leon Tonhäuser', - desc: 'Datenschutzerklärung der Website von Leon Tonhäuser, Sportfotograf aus Uelzen.' + desc: 'Datenschutzerklärung der Website von Leon Tonhäuser, Sportfotograf aus Ebstorf.' }, '/impressum': { title: 'Impressum | Leon Tonhäuser', - desc: 'Impressum und Kontaktdaten von Leon Tonhäuser, Sportfotograf aus Uelzen.' + desc: 'Impressum und Kontaktdaten von Leon Tonhäuser, Sportfotograf aus Ebstorf.' }, '/blog': { title: 'Blog | Leon Tonhäuser', @@ -153,7 +187,7 @@ }, '/404': { title: '404 – Leider nichts gefunden | Leon Tonhäuser', - desc: 'Diese Seite existiert nicht (mehr). Zurück zur Startseite von Leon Tonhäuser, Sportfotograf aus Uelzen.' + desc: 'Diese Seite existiert nicht (mehr). Zurück zur Startseite von Leon Tonhäuser, Sportfotograf aus Ebstorf.' } } }; diff --git a/public/custom/seo.js b/public/custom/seo.js index 643c78e..ff33e6c 100644 --- a/public/custom/seo.js +++ b/public/custom/seo.js @@ -75,6 +75,11 @@ var mail = biz.email; var siteUrl = cfg.SITE_URL; + function placeNode(place) { + if (typeof place === 'string') return { '@type': 'City', name: place }; + return { '@type': place.type, name: place.name }; + } + function personBusinessGraph() { return { '@context': 'https://schema.org', @@ -94,7 +99,7 @@ telephone: phone, email: mail, address: { '@type': 'PostalAddress', addressLocality: b, addressRegion: r, addressCountry: co }, - areaServed: biz.areaServed.map(function (n) { return { '@type': 'City', name: n }; }), + areaServed: biz.areaServed.map(placeNode), priceRange: biz.priceRange } ] @@ -105,7 +110,7 @@ var segs = path.split('/').filter(Boolean); var items = [{ '@type': 'ListItem', position: 1, name: 'Startseite', item: siteUrl + '/' }]; var acc = ''; - var labels = { portfolio: 'Portfolio', leistungen: 'Leistungen', 'über-mich': 'Über mich', kontakt: 'Kontakt', blog: 'Blog', archiv: 'Archiv' }; + var labels = { portfolio: 'Portfolio', leistungen: 'Leistungen', sportfotografie: 'Sportfotografie', eventfotografie: 'Eventfotografie', 'über-mich': 'Über mich', kontakt: 'Kontakt', blog: 'Blog', archiv: 'Archiv' }; for (var i = 0; i < segs.length; i++) { acc += '/' + segs[i]; var label = labels[segs[i]] || segs[i].replace(/^portfolio-/, '').replace(/-/g, ' ').replace(/\b\w/g, function (c) { return c.toUpperCase(); }); @@ -130,17 +135,21 @@ } function serviceGraph() { + var data = page.service || {}; + var serviceType = data.serviceType || biz.serviceType; + var areas = data.areaServed || biz.areaServed; + var services = data.services || biz.services; return { '@context': 'https://schema.org', '@type': 'Service', - serviceType: biz.serviceType, + serviceType: serviceType, provider: { '@type': 'ProfessionalService', name: biz.name, url: siteUrl }, - areaServed: biz.areaServed.map(function (n) { return { '@type': 'City', name: n }; }), + areaServed: areas.map(placeNode), hasOfferCatalog: { '@type': 'OfferCatalog', - name: biz.serviceType + '-Leistungen', - itemListElement: biz.services.map(function (s) { - return { '@type': 'Offer', itemOffered: { '@type': 'Service', name: s } }; + name: serviceType + '-Leistungen', + itemListElement: services.map(function (name) { + return { '@type': 'Offer', itemOffered: { '@type': 'Service', name: name } }; }) } }; diff --git a/public/datenschutz.html b/public/datenschutz.html index e64081e..e86828f 100644 --- a/public/datenschutz.html +++ b/public/datenschutz.html @@ -3,8 +3,8 @@ - Datenschutz | Leon Tonhäuser - + Datenschutzerklärung | Leon Tonhäuser + + + diff --git a/public/impressum.html b/public/impressum.html index a615f5e..801fb6f 100644 --- a/public/impressum.html +++ b/public/impressum.html @@ -4,7 +4,7 @@ Impressum | Leon Tonhäuser - + + diff --git a/public/kontakt.html b/public/kontakt.html index 2918151..a2afa5f 100644 --- a/public/kontakt.html +++ b/public/kontakt.html @@ -3,8 +3,8 @@ - Kontakt | Leon Tonhäuser - + Kontakt | Leon Tonhäuser — Sportfotograf + + diff --git a/public/leistungen.html b/public/leistungen.html index 132207f..bb6b893 100644 --- a/public/leistungen.html +++ b/public/leistungen.html @@ -3,8 +3,8 @@ - Leistungen | Leon Tonhäuser - + Leistungen | Leon Tonhäuser — Sport- & Eventfotografie + - + + diff --git a/public/portfolio-abiball.html b/public/portfolio-abiball.html index 669cfa3..8be079f 100644 --- a/public/portfolio-abiball.html +++ b/public/portfolio-abiball.html @@ -3,7 +3,7 @@ - Abiball | Eventfotografie Uelzen & Lüneburg – Leon Tonhäuser + Abiball | Leon Tonhäuser — Eventfotografie Uelzen & Lüneburg + diff --git a/scripts/bake-seo.mjs b/scripts/bake-seo.mjs index a67568d..21f5a09 100644 --- a/scripts/bake-seo.mjs +++ b/scripts/bake-seo.mjs @@ -27,19 +27,24 @@ const esc = (s) => String(s).replace(/&/g, '&').replace(/"/g, '"').repl const jsonEsc = (s) => String(s).replace(/ s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); +function placeNode(place) { + if (typeof place === 'string') return { '@type': 'City', name: place }; + return { '@type': place.type, name: place.name }; +} + function personBusinessGraph() { return { '@context': 'https://schema.org', '@graph': [ { '@type': 'Person', name: biz.personName, jobTitle: biz.personJobTitle, url: SITE_URL, email: biz.email, telephone: biz.telephone }, { '@type': 'ProfessionalService', name: biz.name, url: SITE_URL, telephone: biz.telephone, email: biz.email, address: { '@type': 'PostalAddress', addressLocality: biz.addressLocality, addressRegion: biz.addressRegion, addressCountry: biz.addressCountry }, - areaServed: biz.areaServed.map((n) => ({ '@type': 'City', name: n })), priceRange: biz.priceRange } + areaServed: biz.areaServed.map(placeNode), priceRange: biz.priceRange } ]}; } function breadcrumbListGraph(p) { const segs = p.split('/').filter(Boolean); const labels = { - portfolio: 'Portfolio', leistungen: 'Leistungen', 'über-mich': 'Über mich', kontakt: 'Kontakt', blog: 'Blog', archiv: 'Archiv', + portfolio: 'Portfolio', leistungen: 'Leistungen', sportfotografie: 'Sportfotografie', eventfotografie: 'Eventfotografie', 'über-mich': 'Über mich', kontakt: 'Kontakt', blog: 'Blog', archiv: 'Archiv', 'portfolio-fc-st-pauli': 'FC St. Pauli', 'portfolio-hamburger-sv': 'Hamburger SV', 'portfolio-frauen-bundesliga': 'Frauen-Bundesliga', 'portfolio-hannover-96': 'Hannover 96', 'portfolio-sv-meppen': 'SV Meppen', 'portfolio-deutschland-u21': 'Deutschland U21', 'portfolio-nfv-pokalfinale-2026': 'NFV-Pokalfinale 2026', 'portfolio-yes-con-2026': 'YES!CON 2026', @@ -58,12 +63,16 @@ function breadcrumbListGraph(p) { return { '@context': 'https://schema.org', '@type': 'BreadcrumbList', itemListElement: items }; } -function serviceGraph() { - return { '@context': 'https://schema.org', '@type': 'Service', serviceType: biz.serviceType, +function serviceGraph(page) { + const data = page.service || {}; + const serviceType = data.serviceType || biz.serviceType; + const areas = data.areaServed || biz.areaServed; + const services = data.services || biz.services; + return { '@context': 'https://schema.org', '@type': 'Service', serviceType, provider: { '@type': 'ProfessionalService', name: biz.name, url: SITE_URL }, - areaServed: biz.areaServed.map((n) => ({ '@type': 'City', name: n })), - hasOfferCatalog: { '@type': 'OfferCatalog', name: biz.serviceType + '-Leistungen', - itemListElement: biz.services.map((s) => ({ '@type': 'Offer', itemOffered: { '@type': 'Service', name: s } })) } }; + areaServed: areas.map(placeNode), + hasOfferCatalog: { '@type': 'OfferCatalog', name: serviceType + '-Leistungen', + itemListElement: services.map((name) => ({ '@type': 'Offer', itemOffered: { '@type': 'Service', name } })) } }; } const BEGIN = ''; @@ -94,7 +103,7 @@ function buildBlock(p) { const s = page.jsonld || []; if (s.includes('person-business')) L.push(``); if (s.includes('breadcrumb')) L.push(``); - if (s.includes('service')) L.push(``); + if (s.includes('service')) L.push(``); L.push(END); return '\t' + L.join('\n\t'); } @@ -104,6 +113,25 @@ for (const f of readdirSync(PUB).filter((x) => x.endsWith('.html'))) { const fp = path.join(PUB, f); const p = f === 'index.html' ? '/' : '/' + f.replace(/\.html$/, ''); let html = readFileSync(fp, 'utf8'); + const page = cfg.PAGES[p] || {}; + if (page.title) { + if (!/[\s\S]*?<\/title>/i.test(html)) { + console.warn('kein <title> in', f); + continue; + } + html = html.replace( + /<title>[\s\S]*?<\/title>/i, + `<title>${esc(page.title)}` + ); + } + if (page.desc) { + const descriptionTag = ``; + if (/]*>/i.test(html)) { + html = html.replace(/]*>/i, descriptionTag); + } else { + html = html.replace('', `\n\t${descriptionTag}`); + } + } const re = new RegExp(reEsc(BEGIN) + '[\\s\\S]*?' + reEsc(END) + '\\n?'); html = html.replace(re, ''); if (!html.includes('')) { console.warn('kein in', f); continue; } @@ -111,4 +139,4 @@ for (const f of readdirSync(PUB).filter((x) => x.endsWith('.html'))) { writeFileSync(fp, html); n++; } -console.log(`Gebacken: ${n} Seiten`); \ No newline at end of file +console.log(`Gebacken: ${n} Seiten`); diff --git a/scripts/check-seo.mjs b/scripts/check-seo.mjs new file mode 100644 index 0000000..18e17b7 --- /dev/null +++ b/scripts/check-seo.mjs @@ -0,0 +1,97 @@ +import assert from 'node:assert/strict'; +import { existsSync, readFileSync, readdirSync } from 'node:fs'; +import path from 'node:path'; +import vm from 'node:vm'; +import { fileURLToPath } from 'node:url'; + +const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..'); +const PUBLIC = path.join(ROOT, 'public'); +const requested = new Set(process.argv.slice(2)); +const wants = (suite) => requested.size === 0 || requested.has('all') || requested.has(suite); +const failures = []; + +function read(relativePath) { + return readFileSync(path.join(ROOT, relativePath), 'utf8'); +} + +function loadConfig() { + const context = { window: {} }; + vm.createContext(context); + vm.runInContext(read('public/custom/seo-config.js'), context); + return context.window.SEO_CONFIG; +} + +function count(text, pattern) { + return (text.match(pattern) || []).length; +} + +function htmlEscape(value) { + return String(value) + .replace(/&/g, '&') + .replace(/"/g, '"') + .replace(//g, '>'); +} + +function check(name, fn) { + try { + fn(); + console.log(`PASS ${name}`); + } catch (error) { + failures.push(`${name}: ${error.message}`); + console.error(`FAIL ${name}: ${error.message}`); + } +} + +if (wants('core')) { + const config = loadConfig(); + const cities = ['Hamburg', 'Hannover', 'Wolfsburg', 'Uelzen', 'Celle', 'Lüneburg']; + + check('Geschäftsort ist Ebstorf', () => { + assert.equal(config.BUSINESS.addressLocality, 'Ebstorf'); + }); + + check('alle sechs Sportregionen sind zentral gepflegt', () => { + assert.deepEqual(Array.from(config.BUSINESS.areaServed), cities); + }); + + check('Sportseite hat seitenspezifische Service-Daten', () => { + const page = config.PAGES['/sportfotografie']; + assert.equal(page.service.serviceType, 'Sportfotografie'); + assert.deepEqual( + Array.from(page.service.areaServed, (place) => place.name), + cities + ); + assert.ok(page.jsonld.includes('service')); + }); + + check('Eventseite hat Hamburg und Deutschland als Einsatzgebiet', () => { + const page = config.PAGES['/eventfotografie']; + assert.deepEqual( + JSON.parse(JSON.stringify(page.service.areaServed)), + [ + { type: 'City', name: 'Hamburg' }, + { type: 'Country', name: 'Deutschland' } + ] + ); + assert.ok(page.jsonld.includes('service')); + }); + + check('gebackener Event-Head entspricht der Konfiguration', () => { + const page = config.PAGES['/eventfotografie']; + const html = read('public/eventfotografie.html'); + assert.equal(count(html, //g), 1); + assert.equal(count(html, /<meta name="description"/g), 1); + assert.ok(html.includes(`<title>${htmlEscape(page.title)}`)); + assert.ok(html.includes(`content="${htmlEscape(page.desc)}"`)); + assert.ok(html.includes('"serviceType":"Eventfotografie"')); + assert.ok(html.includes('"@type":"Country","name":"Deutschland"')); + }); +} + +if (failures.length) { + console.error(`\n${failures.length} Prüfung(en) fehlgeschlagen.`); + process.exit(1); +} + +console.log('\nAlle angeforderten SEO-Prüfungen sind grün.');