SEO: Crawl- und Reputationsgrundlage für die neue Domain

- docs/seo-und-reputation.md: Ist-Zustand, DNS-Records (DMARC/CAA/DNSSEC,
  SPF -all), Einreich-Adressen für Firewall-Kategorien, Backlink-Reihenfolge
- build.py: Verification-Meta-Tokens (Google/Bing), IndexNow-Key-Datei,
  JSON-LD als @graph (ChildCare + WebSite) plus BreadcrumbList je Unterseite,
  lastmod der Sitemap aus dem Git-Commit der Seitenquelle
- layout.html: Platzhalter für Verification-Meta-Tags
- .htaccess: Trailing Slash per 301 auf die kanonische URL
- deploy.sh: IndexNow-Ping nach erfolgreichem Upload (nicht blockierend)
- check.py: validiert JSON-LD und Sitemap-Einträge
This commit is contained in:
torsten 2026-11-30 09:51:56 +01:00
parent 2c7cae11a5
commit edc7f0b863
9 changed files with 411 additions and 28 deletions

View file

@ -14,6 +14,7 @@ from __future__ import annotations
import datetime as dt
import shutil
import subprocess
import sys
from pathlib import Path
@ -23,6 +24,20 @@ OUT = ROOT / "site"
BASE_URL = "https://sonjasrasselbande.de/"
SITE_NAME = "Sonjas Rasselbande"
HOST = "sonjasrasselbande.de"
# --------------------------------------------------- Verifikation & IndexNow
# Sobald die Domain in der Google Search Console bzw. den Bing Webmaster Tools
# angelegt ist, hier den Verification-Token eintragen (leer = kein Meta-Tag):
# GOOGLE_SITE_VERIFICATION = "abc123..." # Meta-Tag google-site-verification
# BING_SITE_VERIFICATION = "1234ABCD..." # Meta-Tag msvalidate.01
# Für IndexNow (Bing, Yandex, Seznam) einen Key (8–128 Zeichen, a–z/0–9)
# eintragen – der Build schreibt daraus <key>.txt ins Web-Root, deploy.sh pingt
# die Sitemap-URLs anschließend an api.indexnow.org. Siehe
# docs/seo-und-reputation.md
GOOGLE_SITE_VERIFICATION = ""
BING_SITE_VERIFICATION = ""
INDEXNOW_KEY = ""
# slug, Navigationslabel (None = nicht in der Navigation), <title>, description,
# robots, indexierbar/in Sitemap
@ -117,32 +132,91 @@ PAGES: list[dict] = [
},
]
JSONLD_HOME = """ <script type="application/ld+json">
{
ORG_ID = f"{BASE_URL}#kindertagespflege"
WEBSITE_ID = f"{BASE_URL}#website"
JSONLD_HOME = f""" <script type="application/ld+json">
{{
"@context": "https://schema.org",
"@type": "ChildCare",
"name": "Sonjas Rasselbande",
"alternateName": "Kindertagespflege Sonja Schmitz",
"description": "Kindertagespflege in Neuss-Rosellen: Betreuung von bis zu fünf Kindern im Alter von 6 Monaten bis 3 Jahren durch eine qualifizierte Tagesmutter.",
"url": "https://sonjasrasselbande.de/",
"telephone": "+49 173 7022020",
"email": "sonja.schmitz79@gmx.de",
"founder": { "@type": "Person", "name": "Sonja Schmitz" },
"address": {
"@type": "PostalAddress",
"streetAddress": "Rosellener Schulstraße 2",
"postalCode": "41470",
"addressLocality": "Neuss",
"addressRegion": "Nordrhein-Westfalen",
"addressCountry": "DE"
},
"areaServed": { "@type": "City", "name": "Neuss" },
"knowsLanguage": "de",
"maximumAttendeeCapacity": 5,
"keywords": "Tagesmutter Neuss, Kindertagespflege Rosellen, Kinderbetreuung unter 3 Jahren, Betreuungsplatz Neuss"
}
"@graph": [
{{
"@type": "ChildCare",
"@id": "{ORG_ID}",
"name": "Sonjas Rasselbande",
"alternateName": "Kindertagespflege Sonja Schmitz",
"description": "Kindertagespflege in Neuss-Rosellen: Betreuung von bis zu fünf Kindern im Alter von 6 Monaten bis 3 Jahren durch eine qualifizierte Tagesmutter.",
"url": "{BASE_URL}",
"telephone": "+49 173 7022020",
"email": "sonja.schmitz79@gmx.de",
"founder": {{ "@type": "Person", "name": "Sonja Schmitz" }},
"address": {{
"@type": "PostalAddress",
"streetAddress": "Rosellener Schulstraße 2",
"postalCode": "41470",
"addressLocality": "Neuss",
"addressRegion": "Nordrhein-Westfalen",
"addressCountry": "DE"
}},
"areaServed": {{ "@type": "City", "name": "Neuss" }},
"knowsLanguage": "de",
"maximumAttendeeCapacity": 5,
"keywords": "Tagesmutter Neuss, Kindertagespflege Rosellen, Kinderbetreuung unter 3 Jahren, Betreuungsplatz Neuss",
"image": "{BASE_URL}assets/img/og-image.png",
"logo": "{BASE_URL}assets/img/logo.svg"
}},
{{
"@type": "WebSite",
"@id": "{WEBSITE_ID}",
"url": "{BASE_URL}",
"name": "{SITE_NAME}",
"inLanguage": "de-DE",
"publisher": {{ "@id": "{ORG_ID}" }}
}}
]
}}
</script>"""
# Breadcrumb-Label für Seiten, die nicht in der Hauptnavigation stehen
CRUMB_LABELS = {
"impressum": "Impressum",
"datenschutz": "Datenschutzerklärung",
}
def verification_meta() -> str:
"""Meta-Tags für die Inhaberschafts-Verifikation (Search Console, Bing)."""
tags = []
if GOOGLE_SITE_VERIFICATION:
tags.append(
f' <meta name="google-site-verification" content="{GOOGLE_SITE_VERIFICATION}">'
)
if BING_SITE_VERIFICATION:
tags.append(f' <meta name="msvalidate.01" content="{BING_SITE_VERIFICATION}">')
return "\n".join(tags)
def jsonld_for(page: dict) -> str:
"""Startseite: ChildCare + WebSite; Unterseiten: BreadcrumbList."""
slug = page["slug"]
if slug == "index":
return JSONLD_HOME
if not page["in_sitemap"]:
return ""
label = page["nav"] or CRUMB_LABELS.get(slug, SITE_NAME)
url = f"{BASE_URL}{slug}.html"
return (
' <script type="application/ld+json">\n'
" {\n"
' "@context": "https://schema.org",\n'
' "@type": "BreadcrumbList",\n'
' "itemListElement": [\n'
f' {{ "@type": "ListItem", "position": 1, "name": "Startseite", "item": "{BASE_URL}" }},\n'
f' {{ "@type": "ListItem", "position": 2, "name": "{label}", "item": "{url}" }}\n'
" ]\n"
" }\n"
" </script>"
)
def nav_html(active_slug: str) -> str:
out = []
@ -178,7 +252,8 @@ def render(page: dict, layout: str) -> str:
"{{nav}}": nav_html(slug),
"{{content}}": fragment,
"{{preload_hero}}": preload_hero,
"{{jsonld}}": JSONLD_HOME if slug == "index" else "",
"{{verification}}": verification_meta(),
"{{jsonld}}": jsonld_for(page),
}
for key, value in replacements.items():
html = html.replace(key, value)
@ -189,8 +264,32 @@ def render(page: dict, layout: str) -> str:
return html
def last_modified(slug: str) -> str:
"""Letzte inhaltliche Änderung einer Seite: Git-Commit-Datum der Quelle.
Wichtig für die Sitemap: ein pauschal auf "heute" gesetztes <lastmod>
ignorieren Crawler als unzuverlässig.
"""
src = SRC / "pages" / f"{slug}.html"
try:
result = subprocess.run(
["git", "log", "-1", "--format=%cs", "--", str(src.relative_to(ROOT))],
cwd=ROOT,
capture_output=True,
text=True,
check=False,
)
stamp = result.stdout.strip()
except OSError:
stamp = ""
if stamp:
return stamp
if src.exists():
return dt.date.fromtimestamp(src.stat().st_mtime).isoformat()
return dt.date.today().isoformat()
def build_sitemap(pages: list[dict]) -> str:
today = dt.date.today().isoformat()
urls = []
for page in pages:
if not page["in_sitemap"]:
@ -199,7 +298,7 @@ def build_sitemap(pages: list[dict]) -> str:
urls.append(
" <url>\n"
f" <loc>{loc}</loc>\n"
f" <lastmod>{today}</lastmod>\n"
f" <lastmod>{last_modified(page['slug'])}</lastmod>\n"
" <changefreq>monthly</changefreq>\n"
f" <priority>{page['priority']}</priority>\n"
" </url>"
@ -247,6 +346,11 @@ def main() -> None:
(OUT / "sitemap.xml").write_text(build_sitemap(PAGES), encoding="utf-8")
print(" ✓ sitemap.xml")
# IndexNow: Key-Datei im Web-Root bestätigt die Inhaberschaft der Domain
if INDEXNOW_KEY:
(OUT / f"{INDEXNOW_KEY}.txt").write_text(INDEXNOW_KEY, encoding="utf-8")
print(f" ✓ {INDEXNOW_KEY}.txt (IndexNow)")
# favicon.ico zusätzlich ins Root (Alt-Browser und Crawler fragen /favicon.ico an)
ico = SRC / "assets" / "img" / "favicon.ico"
if ico.exists():

View file

@ -7,6 +7,7 @@ Exit-Code 1, wenn Probleme gefunden wurden – so auch in CI nutzbar.
from __future__ import annotations
import json
import pathlib
import re
import sys
@ -81,6 +82,15 @@ def main() -> int:
if html.count("<h1") != 1:
problems.append(f"{page.name}: {html.count('<h1')}× <h1> (erwartet: 1)")
for match in re.finditer(r'<script type="application/ld\+json">(.*?)</script>', html, re.S):
try:
data = json.loads(match.group(1))
except json.JSONDecodeError as exc:
problems.append(f"{page.name}: ungültiges JSON-LD ({exc})")
continue
if not data.get("@type") and not data.get("@graph"):
problems.append(f"{page.name}: JSON-LD ohne @type/@graph")
for match in re.finditer(r'(?:href|src)="([^"#][^"]*)"', html):
target = match.group(1)
if target.startswith(("http://", "https://", "mailto:", "tel:", "data:")):
@ -93,6 +103,18 @@ def main() -> int:
if "alt=" not in tag:
problems.append(f"{page.name}: <img> ohne alt – {tag[:60]}")
# Sitemap gegen die gebauten Dateien prüfen (Crawlbarkeit)
sitemap = (SITE / "sitemap.xml").read_text(encoding="utf-8")
locs = re.findall(r"<loc>(.*?)</loc>", sitemap)
if not locs:
problems.append("sitemap.xml enthält keine <loc>-Einträge")
for loc in locs:
rel = loc.split("sonjasrasselbande.de/", 1)[-1] or "index.html"
if not (SITE / rel).exists():
problems.append(f"sitemap.xml: Eintrag ohne Datei – {loc}")
if "Sitemap:" not in (SITE / "robots.txt").read_text(encoding="utf-8"):
problems.append("robots.txt verweist nicht auf die Sitemap")
total_kb = sum(f.stat().st_size for f in SITE.rglob("*") if f.is_file()) / 1024
print(f"{len(pages)} Seiten geprüft, {total_kb:.0f} KB gesamt")

View file

@ -114,3 +114,40 @@ if [ "$DRY_RUN" -eq 0 ]; then
exit 1
fi
fi
# ------------------------------------------------------------------ IndexNow
# Meldet die Sitemap-URLs bei api.indexnow.org an (Bing, Yandex, Seznam, Naver).
# Voraussetzung: INDEXNOW_KEY in scripts/build.py gesetzt – der Build legt dann
# <key>.txt im Web-Root an, die als Nachweis dient. Details:
# docs/seo-und-reputation.md
if [ "$DRY_RUN" -eq 0 ] && [ "$REMOTE_DIR" = "/" ] && [ -f "$SITE/sitemap.xml" ]; then
KEY_FILE="$(find "$SITE" -maxdepth 1 -name '*.txt' ! -name 'robots.txt' -print -quit)"
if [ -n "$KEY_FILE" ]; then
echo "▶ IndexNow"
python3 - "$(basename "$KEY_FILE" .txt)" "$SITE/sitemap.xml" <<'PY'
import json, re, sys, urllib.request
key, sitemap = sys.argv[1], sys.argv[2]
host = "sonjasrasselbande.de"
urls = re.findall(r"<loc>(.*?)</loc>", open(sitemap, encoding="utf-8").read())
payload = {
"host": host,
"key": key,
"keyLocation": f"https://{host}/{key}.txt",
"urlList": urls,
}
req = urllib.request.Request(
"https://api.indexnow.org/indexnow",
data=json.dumps(payload).encode("utf-8"),
headers={"Content-Type": "application/json; charset=utf-8",
"User-Agent": "sonjasrasselbande-deploy"},
method="POST",
)
try:
with urllib.request.urlopen(req, timeout=20) as res:
print(f" ✓ {len(urls)} URL(s) gemeldet (HTTP {res.status})")
except Exception as exc: # IndexNow ist optional, nie deploy-blockierend
print(f" · IndexNow nicht bestätigt: {exc}")
PY
fi
fi