SEO-Grundlagen und Vorarbeit für Anzeigen

Bisher fehlte alles, womit Suchmaschinen arbeiten: keine robots.txt,
keine Sitemap, keine strukturierten Daten. Jetzt:

- sitemap.xml zur Laufzeit erzeugt, damit die Produktseiten aus Medusa
  mit drin sind — eine Erweiterung kennt beim Bauen nur die festen Seiten
- robots.txt, die Warenkorb, Kasse und Konto ausnimmt
- Organisationsdaten im Layout, Produkt- und Brotkrumendaten auf der
  Produktseite, damit in der Trefferliste Preis und Verfügbarkeit stehen
  können statt nur ein blauer Link
- jede Seite hat jetzt genau eine h1; im Hero war der Claim eine h2, die
  Seiten hatten damit gar keine Hauptüberschrift
- die Weiterleitung der Startseite ist dauerhaft (301) statt vorübergehend

Für Anzeigen: produktdaten.xml als Feed fürs Merchant Center, eine Zeile
je Variante, ohne Gutscheine, Patenschaften und Abo. Dazu die Meldung des
Kaufabschlusses an Google — nur wenn eingewilligt wurde, und einmal je
Bestellung.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
torbinus
2026-09-29 08:37:40 +02:00
parent a5ac198ec5
commit 840e62ddaa
13 changed files with 305 additions and 14 deletions
+10
View File
@@ -0,0 +1,10 @@
# Suchmaschinen dürfen alles lesen außer den Seiten, die eine Sitzung
# brauchen oder für Suchende keinen Wert haben.
User-agent: *
Disallow: /warenkorb
Disallow: /kasse
Disallow: /konto
Disallow: /bestellung
Disallow: /admin
Sitemap: https://place4bees.com/sitemap.xml
@@ -34,7 +34,8 @@ const schritte = [
];
---
<!-- 1 · Hero. min-height 70vh, Claim als h2 rechtsbündig. -->
<!-- 1 · Hero. min-height 70vh, Claim als h1 rechtsbündig — er ist die
Hauptüberschrift der Seite. -->
<section class="p4b-hero hero-video relative flex min-h-[70vh] items-end overflow-hidden pb-5">
<img
src="/images/p4b/hero-video-poster.jpg"
@@ -61,9 +62,9 @@ const schritte = [
Inhaltsrasters — sonst schwebt er mitten im Foto. Nur der Seitenabstand
bleibt, damit er auf schmalen Schirmen nicht an der Kante klebt. */}
<div class="relative w-full px-[30px]">
<h2 class="p4b-h2 text-right">
<h1 class="p4b-h2 text-right">
Eigene Bienen vor&nbsp;Ort.<br />Professionell betreut.<br />Nachhaltig&nbsp;erlebbar.
</h2>
</h1>
</div>
</section>
+25
View File
@@ -89,6 +89,31 @@ const gaId = process.env.PUBLIC_GA_ID ?? import.meta.env.PUBLIC_GA_ID ?? "";
{image && <meta property="og:image" content={image} />}
<meta name="twitter:card" content="summary_large_image" />
{/* Strukturierte Daten: Damit Suchmaschinen das Unternehmen als solches
erkennen und in der Trefferliste Name, Logo und Kontakt zeigen können.
Steht einmal im Layout und gilt damit für jede Seite. */}
<script
type="application/ld+json"
is:inline
set:html={JSON.stringify({
"@context": "https://schema.org",
"@type": "Organization",
name: "PLACE4BEES GmbH",
alternateName: COMPANY_NAME,
url: PRIMARY_DOMAIN,
logo: `${PRIMARY_DOMAIN}/images/newLogo.png`,
email: "kontakt@place4bees.com",
telephone: "+491622350202",
address: {
"@type": "PostalAddress",
streetAddress: "Isestraße 109",
postalCode: "20149",
addressLocality: "Hamburg",
addressCountry: "DE",
},
})}
/>
<!-- Seitenwechsel als View Transition statt hartem Neuaufbau. -->
<ClientRouter />
+23
View File
@@ -50,6 +50,29 @@ import Layout from "../../layouts/Layout.astro";
const order = JSON.parse(raw);
el.textContent = `Bestellnummer ${order.display_id ?? order.id}. Eine Bestätigung geht an ${order.email}.`;
// Kaufabschluss an Google melden — aber nur, wenn zugestimmt wurde.
// Ohne Einwilligung ist window.gtag gar nicht erst geladen, deshalb
// reicht die Prüfung darauf. Der Schlüssel in sessionStorage verhindert,
// dass ein Neuladen der Seite denselben Kauf doppelt zählt.
const gemeldet = `p4b_gemeldet_${order.id}`;
if (window.gtag && !sessionStorage.getItem(gemeldet)) {
window.gtag("event", "purchase", {
transaction_id: order.display_id ?? order.id,
value: order.total ?? 0,
currency: (order.currency_code ?? "eur").toUpperCase(),
shipping: order.shipping_total ?? 0,
tax: order.tax_total ?? 0,
items: (order.items ?? []).map((posten: any) => ({
item_id: posten.variant_id ?? posten.id,
item_name: posten.product_title ?? posten.title,
item_variant: posten.variant_title,
price: posten.unit_price ?? 0,
quantity: posten.quantity ?? 1,
})),
});
sessionStorage.setItem(gemeldet, "1");
}
if (invoiceButton && order.id) {
invoiceButton.classList.remove("hidden");
invoiceButton.addEventListener("click", async () => {
@@ -83,9 +83,9 @@ const leistungen = [
style="background-image: url('/images/p4b/kontakt-bild-1.jpg')"
>
<div class="p4b-breite w-full">
<h2 class="p4b-h2 is-hell text-right">
<h1 class="p4b-h2 is-hell text-right">
Eigene Bienen vor&nbsp;Ort.<br />Professionell betreut.<br />Nachhaltig&nbsp;erlebbar.
</h2>
</h1>
</div>
</section>
+2 -2
View File
@@ -21,9 +21,9 @@ import KontaktVersand from "../../components/KontaktVersand.astro";
style="background-image: url('/images/p4b/kontakt-bild-3.jpg')"
>
<div class="p4b-breite w-full">
<h2 class="p4b-h2 is-hell text-right">
<h1 class="p4b-h2 is-hell text-right">
Partnerschaftliche<br />Vertrauensvolle<br />Zusammenarbeit
</h2>
</h1>
</div>
</section>
@@ -26,9 +26,9 @@ const werte = [
style="background-image: url('/images/p4b/philosophie-bild-15.jpg')"
>
<div class="p4b-breite w-full">
<h2 class="p4b-h2 is-hell text-right">
<h1 class="p4b-h2 is-hell text-right">
Verantwortung.<br />Regionalität.<br />Wertschätzung.
</h2>
</h1>
</div>
</section>
+2 -2
View File
@@ -37,9 +37,9 @@ const mitteilungen = [
style="background-image: url('/images/p4b/philosophie-bild-15.jpg')"
>
<div class="p4b-breite w-full">
<h2 class="p4b-h2 is-hell text-right">
<h1 class="p4b-h2 is-hell text-right">
Verantwortung.<br />Regionalität.<br />Wertschätzung.
</h2>
</h1>
</div>
</section>
+2 -2
View File
@@ -35,9 +35,9 @@ const team = [
style="background-image: url('/images/p4b/ueberuns-9-scaled.jpg'); background-position: center top"
>
<div class="p4b-breite w-full">
<h2 class="p4b-h2 text-right">
<h1 class="p4b-h2 text-right">
Eigene Bienen vor&nbsp;Ort.<br />Professionell betreut.<br />Nachhaltig&nbsp;erlebbar.
</h2>
</h1>
</div>
</section>
+3 -1
View File
@@ -33,7 +33,9 @@ try {
}
if (!showBusiness || kommtVonHhonig) {
return Astro.redirect(`/shop${Astro.url.search}`);
// 301 statt 302: Nur bei einer dauerhaften Weiterleitung schreiben
// Suchmaschinen die Bewertung auf das Ziel um.
return Astro.redirect(`/shop${Astro.url.search}`, 301);
}
---
+97
View File
@@ -0,0 +1,97 @@
import type { APIRoute } from "astro";
import { PRIMARY_DOMAIN } from "../lib/sections";
import { listProducts, getDefaultRegion } from "../lib/medusa";
export const prerender = false;
/**
* Produktdatenfeed für das Google Merchant Center — die Grundlage für
* Shopping-Anzeigen und kostenlose Produkteinträge in der Suche.
*
* Die Adresse wird im Merchant Center einmal hinterlegt, Google holt sie
* danach selbst regelmäßig ab. Eine Zeile je Variante, nicht je Produkt:
* 250 und 500 Gramm sind für Google zwei Artikel mit eigenem Preis.
*
* Ohne EAN und Herstellernummer verlangt Google die ausdrückliche Angabe
* `identifier_exists = no`. Für selbst abgefüllten Honig ist das richtig —
* sobald es Strichcodes gibt, gehört die EAN hier hinein.
*/
export const GET: APIRoute = async () => {
let produkte: any[] = [];
try {
const region = await getDefaultRegion();
produkte = await listProducts(region.id);
} catch {
// Lieber ein leerer Feed als ein Fehler: Google wertet einen Abbruch als
// Störung und meldet das Konto auffällig.
}
const esc = (text: unknown) =>
String(text ?? "")
.replace(/&/g, "&amp;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;");
const eintraege: string[] = [];
for (const produkt of produkte) {
// Was nicht versendet wird, gehört nicht in einen Shopping-Feed:
// Gutscheine, Patenschaften, Kurse und das Abo.
if (
produkt.metadata?.gift_voucher ||
produkt.metadata?.sponsorship ||
produkt.metadata?.subscription
) {
continue;
}
const bild = produkt.thumbnail ?? produkt.images?.[0]?.url ?? "";
const bildUrl = bild.startsWith("http") ? bild : `${PRIMARY_DOMAIN}${bild}`;
for (const variante of produkt.variants ?? []) {
const preis = variante.calculated_price?.calculated_amount;
if (preis == null) continue;
const titel =
(produkt.variants?.length ?? 0) > 1 && variante.title !== "Default Title"
? `${produkt.title} – ${variante.title}`
: produkt.title;
eintraege.push(
` <item>
<g:id>${esc(variante.id)}</g:id>
<g:item_group_id>${esc(produkt.id)}</g:item_group_id>
<g:title>${esc(titel)}</g:title>
<g:description>${esc(produkt.description ?? produkt.title)}</g:description>
<g:link>${PRIMARY_DOMAIN}/shop/${esc(produkt.handle)}</g:link>
${bild ? `<g:image_link>${esc(bildUrl)}</g:image_link>` : ""}
<g:availability>in_stock</g:availability>
<g:condition>new</g:condition>
<g:price>${Number(preis).toFixed(2)} EUR</g:price>
<g:brand>PLACE4BEES</g:brand>
<g:identifier_exists>no</g:identifier_exists>
${variante.metadata?.net_weight_grams ? `<g:unit_pricing_measure>${variante.metadata.net_weight_grams} g</g:unit_pricing_measure>\n <g:unit_pricing_base_measure>1000 g</g:unit_pricing_base_measure>` : ""}
<g:google_product_category>424</g:google_product_category>
</item>`
);
}
}
const xml = `<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:g="http://base.google.com/ns/1.0">
<channel>
<title>PLACE4BEES – Honig aus Hamburg</title>
<link>${PRIMARY_DOMAIN}/shop</link>
<description>Regionaler Honig, Bienenprodukte und Geschenkideen aus Hamburg.</description>
${eintraege.join("\n")}
</channel>
</rss>
`;
return new Response(xml, {
headers: {
"Content-Type": "application/xml; charset=utf-8",
"Cache-Control": "public, max-age=3600",
},
});
};
+56
View File
@@ -7,6 +7,7 @@ import GiftVoucherOptions from "../../components/GiftVoucherOptions.astro";
import { getProductByHandle, getDefaultRegion, listHoneyVarieties, getShopSettings, getGiftShippingSurcharge } from "../../lib/medusa";
import { formatEUR, formatEURKurz, formatGrundpreis } from "../../lib/format";
import { findVariety, COLLECTION_LABELS } from "../../lib/varieties";
import { PRIMARY_DOMAIN } from "../../lib/sections";
export const prerender = false;
@@ -63,9 +64,64 @@ const variety = findVariety(product.title);
// Aus den Shop-Einstellungen, damit hier nichts steht, was an der Kasse
// nicht gilt.
const { freeShippingThreshold } = await getShopSettings();
// Strukturierte Daten für Suchmaschinen: Damit in der Trefferliste Preis und
// Verfügbarkeit stehen können und nicht nur ein blauer Link. Jede Variante
// wird als eigenes Angebot ausgewiesen, weil sich die Preise unterscheiden.
// Die Brotkrumen darunter zeigen, wo die Seite im Shop hängt.
const angebote = product.variants
.filter((v) => v.calculated_price)
.map((v) => ({
"@type": "Offer",
name: v.title,
price: (v.calculated_price!.calculated_amount).toFixed(2),
priceCurrency: "EUR",
availability: "https://schema.org/InStock",
url: `${PRIMARY_DOMAIN}/shop/${product.handle}`,
itemCondition: "https://schema.org/NewCondition",
}));
const produktDaten = {
"@context": "https://schema.org",
"@type": "Product",
name: product.title,
description: product.description ?? product.title,
image: gallery.map((bild) => (bild.startsWith("http") ? bild : `${PRIMARY_DOMAIN}${bild}`)),
brand: { "@type": "Brand", name: "PLACE4BEES" },
...(angebote.length === 1 ? { offers: angebote[0] } : {}),
...(angebote.length > 1
? {
offers: {
"@type": "AggregateOffer",
priceCurrency: "EUR",
lowPrice: Math.min(...angebote.map((a) => Number(a.price))).toFixed(2),
highPrice: Math.max(...angebote.map((a) => Number(a.price))).toFixed(2),
offerCount: angebote.length,
offers: angebote,
},
}
: {}),
};
const brotkrumenDaten = {
"@context": "https://schema.org",
"@type": "BreadcrumbList",
itemListElement: [
{ "@type": "ListItem", position: 1, name: "Shop", item: `${PRIMARY_DOMAIN}/shop` },
...(categoryName ? [{ "@type": "ListItem", position: 2, name: categoryName }] : []),
{
"@type": "ListItem",
position: categoryName ? 3 : 2,
name: product.title,
item: `${PRIMARY_DOMAIN}/shop/${product.handle}`,
},
],
};
---
<Layout title={product.title} description={product.description ?? product.title}>
<script type="application/ld+json" is:inline set:html={JSON.stringify(produktDaten)} />
<script type="application/ld+json" is:inline set:html={JSON.stringify(brotkrumenDaten)} />
<section class="brand-section bg-brand-surface-strong pt-24 pb-[var(--section-y)] sm:pt-28">
<div class="mx-auto max-w-[84rem] px-[var(--gutter)]">
<nav aria-label="Brotkrumen" class="flex flex-wrap items-center gap-2 text-sm text-brand-text-muted">
+77
View File
@@ -0,0 +1,77 @@
import type { APIRoute } from "astro";
import { PRIMARY_DOMAIN } from "../lib/sections";
import { listProducts, getDefaultRegion } from "../lib/medusa";
export const prerender = false;
/**
* Sitemap für Suchmaschinen.
*
* Von Hand statt über eine Erweiterung, weil die Produktseiten erst zur
* Laufzeit aus Medusa kommen — eine Erweiterung kennt beim Bauen nur die
* festen Seiten und ließe ausgerechnet den Shop aus.
*
* Nicht enthalten: alles hinter der Anmeldung, Warenkorb und Kasse. Diese
* Seiten haben für Suchende keinen Wert, und ihr Inhalt hängt an einer
* Sitzung.
*/
const SEITEN: { pfad: string; prioritaet: number; frequenz: string }[] = [
{ pfad: "/business", prioritaet: 1.0, frequenz: "weekly" },
{ pfad: "/shop", prioritaet: 1.0, frequenz: "daily" },
{ pfad: "/privatkunden", prioritaet: 0.9, frequenz: "weekly" },
{ pfad: "/automaten", prioritaet: 0.9, frequenz: "weekly" },
{ pfad: "/business/ihr-projekt", prioritaet: 0.8, frequenz: "monthly" },
{ pfad: "/business/philosophie", prioritaet: 0.7, frequenz: "monthly" },
{ pfad: "/business/ueber-uns", prioritaet: 0.7, frequenz: "monthly" },
{ pfad: "/business/presse", prioritaet: 0.6, frequenz: "monthly" },
{ pfad: "/business/kontakt", prioritaet: 0.7, frequenz: "monthly" },
{ pfad: "/ueber-uns", prioritaet: 0.7, frequenz: "monthly" },
{ pfad: "/kontakt", prioritaet: 0.7, frequenz: "monthly" },
{ pfad: "/versand", prioritaet: 0.5, frequenz: "monthly" },
{ pfad: "/agb", prioritaet: 0.3, frequenz: "yearly" },
{ pfad: "/widerrufsrecht", prioritaet: 0.3, frequenz: "yearly" },
{ pfad: "/datenschutz", prioritaet: 0.3, frequenz: "yearly" },
{ pfad: "/impressum", prioritaet: 0.3, frequenz: "yearly" },
{ pfad: "/kuendigung", prioritaet: 0.3, frequenz: "yearly" },
];
export const GET: APIRoute = async () => {
let produkte: { handle: string; updated_at?: string }[] = [];
try {
// Ohne Region weigert sich Medusa, weil zu jedem Produkt ein Preis
// berechnet wird. Für die Sitemap brauchen wir ihn nicht, der Aufruf
// verlangt ihn aber.
const region = await getDefaultRegion();
const geladen = await listProducts(region.id);
produkte = geladen.map((p: any) => ({ handle: p.handle, updated_at: p.updated_at }));
} catch {
// Fällt das Backend aus, soll die Sitemap trotzdem ausgeliefert werden —
// dann eben nur mit den festen Seiten statt mit einem Fehler.
}
const heute = new Date().toISOString().slice(0, 10);
const eintrag = (pfad: string, prioritaet: number, frequenz: string, datum = heute) =>
` <url>\n <loc>${PRIMARY_DOMAIN}${pfad}</loc>\n <lastmod>${datum}</lastmod>\n` +
` <changefreq>${frequenz}</changefreq>\n <priority>${prioritaet.toFixed(1)}</priority>\n </url>`;
const xml =
`<?xml version="1.0" encoding="UTF-8"?>\n` +
`<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n` +
[
...SEITEN.map((s) => eintrag(s.pfad, s.prioritaet, s.frequenz)),
...produkte.map((p) =>
eintrag(`/shop/${p.handle}`, 0.8, "weekly", (p.updated_at ?? heute).slice(0, 10))
),
].join("\n") +
`\n</urlset>\n`;
return new Response(xml, {
headers: {
"Content-Type": "application/xml; charset=utf-8",
// Eine Stunde Zwischenspeicher: Suchmaschinen holen sie ohnehin selten,
// und neue Produkte sind schnell genug drin.
"Cache-Control": "public, max-age=3600",
},
});
};