Merge SEO, GEO and Search Console track

Conflict in createContentHelpers.ts resolved by keeping both: isPathVisible (per-path, security track) and constructionPaths (per-list, SEO track).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

# Conflicts:
#	src/modules/frontend/createContentHelpers.ts
This commit is contained in:
Radosław Smoliński
2026-10-22 17:48:22 +02:00
25 changed files with 1255 additions and 78 deletions
+10 -3
View File
@@ -1,6 +1,6 @@
---
name: ipal-seo-check
description: Checks a running ipal-kit site the way Googlebot and AI agents see it — metadata inside <head> (not streamed to body), title, description, self canonical, hreflang with x-default, noindex pages leaking into the sitemap, error pages in the sitemap, robots.txt, soft 404s, favicon, JSON-LD, and GEO (llms.txt, llms-full.txt, Markdown version, text/markdown alternate, MCP server, AI bots in robots, health). Use after building pages, before handing over, after deploys, after an ipal-kit upgrade, and whenever SEO, indexing, Search Console or "Google doesn't see" problems come up.
description: Checks a running ipal-kit site the way Googlebot and AI agents see it — metadata inside <head> (not streamed to body), title, description, self canonical, hreflang with x-default, noindex pages leaking into the sitemap, error pages in the sitemap, sitemap index parts, Search Console / Bing verification tags, robots.txt, soft 404s, favicon, JSON-LD, and GEO (llms.txt, llms-full.txt, Markdown version, text/markdown alternate, MCP server, AI bots in robots, health). Use after building pages, before handing over, after deploys, after an ipal-kit upgrade, and whenever SEO, indexing, Search Console or "Google doesn't see" problems come up.
---
# ipal-seo-check
@@ -31,11 +31,18 @@ Sprawdza **działającą** aplikację, nie kod — dokładnie to, co dostaje Goo
| no JSON-LD structured data | brak `<SiteProviders>` / `<JsonLdGraph>` w `[locale]/layout.tsx` albo pusta nazwa w Site Settings |
| `/llms.txt` / `/llms-full.txt` → 404 | brak trasy (`export { llmsRoute as GET }` / `llmsFullRoute` z `lib/content`) |
| Markdown version `/md/…` → 404 | brak `src/app/md/[locale]/[[...slug]]/route.ts`; strona noindex/draft |
| `sitemap.xml → 503` | baza niedostępna przy budowaniu sitemapy (`sitemapRoute` zwraca 503 + Retry-After zamiast pustej) — sprawdź `DATABASE_URL` / zdrowie bazy |
| sitemap index parts not 200 | serwis > `maxUrls` (10 000) → `/sitemap.xml` to index; części `?part=N` muszą odpowiadać 200 — własna trasa bez obsługi `part` albo cache CDN ze starą liczbą części |
| MCP not answering initialize | brak `src/app/api/mcp/route.ts` albo Cloudflare Access bez Bypass (mcp.md) |
3. `[WARNING]` oceń: brak opisu / zduplikowane tytuły to **treść w panelu** —
3. `no verification meta tag` (INFO — not counted as an error or warning) — with domain
verification by DNS (recommended) this is the correct state; do nothing. Only for
URL-prefix verification, paste the code in **Site Settings → Search & AI**.
`robots.txt blocks AI bots` — sprawdź też Site Settings → Search & AI → AI crawlers
(gdy projekt używa `getRobots`, redaktor mógł zmienić politykę).
4. `[WARNING]` oceń: brak opisu / zduplikowane tytuły to **treść w panelu** —
uzupełnij z briefu albo wypisz w raporcie dla klienta.
4. Uruchom ponownie aż `0 error(s)`.
5. Uruchom ponownie aż `0 error(s)`.
## Czego skrypt nie sprawdzi
Search Console (indeksacja, ręczne działania), Core Web Vitals, poprawność
@@ -29,7 +29,8 @@ let warnings = 0
const findings = []
const report = (level, title, rule, items = []) => {
if (level === 'ERROR') errors += Math.max(items.length, 1)
else warnings += Math.max(items.length, 1)
else if (level === 'WARNING') warnings += Math.max(items.length, 1)
// INFO: shown, never counted — a note, not a problem
findings.push({ level, title, rule, items })
}
const get = async (path, opts = {}) => {
@@ -73,14 +74,30 @@ else {
const sitemap = await get('/sitemap.xml')
let urls = []
let hasAlternates = false
if (sitemap.res.status !== 200) report('ERROR', `sitemap.xml → ${sitemap.res.status}`, 'export sitemap from lib/content + force-dynamic')
const locs = (xml) => [...xml.matchAll(/<loc>\s*([^<\s]+)\s*<\/loc>/g)].map((m) => m[1].replace(/&amp;/g, '&'))
if (sitemap.res.status === 503) report('ERROR', 'sitemap.xml → 503', 'the database was unreachable while building it (sitemapRoute answers 503 + Retry-After) — check DATABASE_URL / DB health')
else if (sitemap.res.status !== 200) report('ERROR', `sitemap.xml → ${sitemap.res.status}`, 'export sitemapRoute (or sitemap) from lib/content + force-dynamic')
else {
urls = [...new Set([...sitemap.text.matchAll(/<loc>\s*([^<\s]+)\s*<\/loc>/g)].map((m) => m[1]))]
hasAlternates = /hreflang=/.test(sitemap.text)
let xml = sitemap.text
// Large sites: /sitemap.xml is a <sitemapindex> of parts (?part=N) — read every part.
if (/<sitemapindex/i.test(xml)) {
const parts = locs(xml)
const broken = []
xml = ''
for (const part of parts.slice(0, 50)) {
const r = await get(part).catch(() => null)
if (!r || r.res.status !== 200) broken.push(`${part} → ${r?.res.status ?? 'unreachable'}`)
else xml += r.text
}
console.log(`sitemap index: ${parts.length} part(s)`)
if (broken.length) report('ERROR', 'sitemap index parts not 200', 'every <sitemap><loc> must answer 200 (seo.md → Duży serwis)', broken)
}
urls = [...new Set(locs(xml))]
hasAlternates = /hreflang=/.test(xml)
if (urls.length === 0) report('ERROR', 'sitemap.xml is empty', 'DB unreachable at build without force-dynamic, or no published pages')
const foreign = urls.filter((u) => !u.startsWith('http') || /localhost|127\.0\.0\.1/.test(u) !== /localhost|127\.0\.0\.1/.test(origin))
if (foreign.length) report('ERROR', 'sitemap URLs relative or on another host', 'NEXT_PUBLIC_SERVER_URL / baseUrl', foreign.slice(0, 5))
if (/(\/404|\/500|not-found)(\/|<|$)/.test(sitemap.text)) report('ERROR', 'error pages listed in the sitemap', 'pages.md — 404 page is excluded by ID')
if (/(\/404|\/500|not-found)(\/|<|$)/.test(xml)) report('ERROR', 'error pages listed in the sitemap', 'pages.md — 404 page is excluded by ID')
}
// --- 4. sampled pages -----------------------------------------------------
@@ -209,6 +226,17 @@ if (issues.noLinks.length) report('WARNING', 'pages without internal links', 'li
if (!skipped('jsonld') && issues.jsonLd.length) report('ERROR', 'no JSON-LD structured data', '<JsonLdGraph> WebSite + Organization in [locale]/layout.tsx (AGENT.md §0b.4)', issues.jsonLd.slice(0, 5))
if (!skipped('markdown') && issues.mdAlt.length) report('WARNING', 'no text/markdown alternate link in head', 'createContentHelpers({ markdownAlternate: true }) (AGENT.md §0b.6)', issues.mdAlt.slice(0, 3))
// --- 4b. Search Console / Bing verification tags (Site Settings → Search & AI) ----
// INFO only: domain (DNS) verification — the recommended route — leaves the tags empty.
if (!skipped('verification') && sample.length) {
const page = await get(sample[0]).catch(() => null)
const head = page?.text.split(/<\/head>/i)[0] ?? ''
const missing = [['google-site-verification', 'Google Search Console'], ['msvalidate.01', 'Bing Webmaster Tools']]
.filter(([name]) => !new RegExp(`<meta[^>]+name="${name}"`, 'i').test(head))
.map(([, label]) => label)
if (missing.length) report('INFO', 'no verification meta tag (fine with DNS / domain verification)', 'only for URL-prefix verification: paste the code in Site Settings → Search & AI', missing)
}
// --- 5. 404 ---------------------------------------------------------------
const firstLocale = [...byLocale.keys()].find((l) => l && l.length <= 5) ?? ''
for (const path of [`/${firstLocale ? firstLocale + '/' : ''}ipal-seo-check-${Date.now()}`]) {
+158 -6
View File
@@ -306,7 +306,16 @@ Co zawiera sitemapa:
- `lastModified` z realnego `updatedAt` dokumentu
- wpisy bloga z prefiksem archiwum (`/pl/artykuly/moj-post`)
Pomija: drafty (`_status !== 'published'`) i dokumenty z `meta.noindex`.
Pomija: drafty (`_status !== 'published'`) i dokumenty z `meta.noindex`. Gdy
**Site Settings → Under construction** jest włączone — wszystko poza stronami, które
zostają otwarte (strona główna + „Pages still available”), bo reszta przekierowuje na
komunikat i crawler zaindeksowałby go zamiast treści. To samo robi `llms.txt`.
Duże kolekcje (1.13): dokumenty czytane partiami po 500 (`SITEMAP_BATCH_SIZE`), tylko
opublikowane (`where _status` przy kolekcji z draftami) i tylko potrzebne pola
(`select`: slug, updatedAt, noindex, meta). Własne `sitemapImages` może czytać dowolne
pole, więc wtedy czytany jest cały dokument (`buildSitemapEntries({ select: true })`
wymusza select).
Niskopoziomowo (własna trasa zamiast handlera z fabryki):
@@ -318,8 +327,47 @@ const entries = await buildSitemapEntries({
})
```
Przy dziesiątkach tysięcy URL-i Next ma `generateSitemaps` do dzielenia na
części — dodasz, gdyby realnie było ich tyle. Jedna sitemapa wystarcza do ~50k.
### Duży serwis — sitemap index, cache, błędy (1.13)
`sitemapRoute` (`createSitemapRouteHandler`) dzieli sitemapę sam, gdy URL-i jest więcej
niż `maxUrls` (domyślnie 10 000 — protokół pozwala 50 000 / 50 MB, ale hreflang robi
z każdego URL-a kilka linii):
- `/sitemap.xml` → `<sitemapindex>` z częściami `/sitemap.xml?part=1`, `?part=2`…;
każda część ma `lastmod` = najnowszy `lastmod` jej URL-i.
- robots.txt i Search Console zostają przy jednym adresie `/sitemap.xml`.
- Nieistniejąca część → 404.
| Opcja | Domyślnie | Co robi |
|---|---|---|
| `maxUrls` | `10000` | URL-i w jednym pliku; powyżej — index + części |
| `cacheControl` | `public, max-age=0, s-maxage=3600, stale-while-revalidate=86400` | CDN trzyma godzinę, przeglądarka sprawdza za każdym razem; `false` = bez nagłówka |
| `memoSeconds` | `300` | ile sekund proces trzyma zbudowaną listę (index i części nie budują jej od nowa); `0` = wyłączone |
```ts
createContentHelpers({ …, sitemapOptions: { maxUrls: 5000, memoSeconds: 0 } }) // sitemapRoute
createSitemapRouteHandler(sitemap, { maxUrls: 5000, memoSeconds: 0 }) // własna trasa
```
Ostatnie słowo ma projekt — `sitemapEntries` dostaje wpisy pluginu i zwraca listę do
publikacji (dodaj adresy własnych tras, usuń, ustaw `priority`):
```ts
createContentHelpers({ …,
sitemapEntries: (entries) => [...entries, { url: `${origin}/kalkulator`, lastModified: new Date() }],
})
```
Filtr „Under construction” w sitemapie i llms.txt wyłączasz `underConstructionSeo: false`.
Błąd bazy w runtime → **503 + `Retry-After: 300`** (crawler wróci), nie pusta sitemapa
z 200 („strona nie ma podstron”). Pusta odpowiedź i błąd nigdy nie idą z cache.
Wyjątek: `next build` (`NEXT_PHASE=phase-production-build`) dalej dostaje pustą,
poprawną sitemapę, żeby build bez bazy nie padł. `sitemap()` z `createContentHelpers`
też rzuca błąd w runtime (wcześniej zwracał `[]`).
`app/sitemap.ts` (MetadataRoute) nie dzieli — przy dużym serwisie użyj `sitemapRoute`.
Własna trasa: `buildSitemapIndexXml([{ url, lastModified }], { cssUrl })` składa sam index.
## Favicon w Google + Organization (branding w wyszukiwarce)
@@ -557,7 +605,7 @@ export const revalidate = 3600 // cache 1h, regeneracja w tle
> pokaże zmian redaktora od razu (czeka do rewalidacji). Dla treści zmienianej
> rzadko OK. Jeśli redaktor ma widzieć zmiany natychmiast — użyj **on-demand
> revalidation**: hook `afterChange` w kolekcji → `revalidatePath(path)` (patrz
> HOOKS.md). Albo krótszy `revalidate` (np. 300 = 5 min). NIE łącz ISR z
> [hooks.md](./hooks.md)). Albo krótszy `revalidate` (np. 300 = 5 min). NIE łącz ISR z
> `force-dynamic` — wykluczają się.
### Rozwiązanie DRUGIE — usuń jawny <head> z layoutu
@@ -1036,6 +1084,15 @@ Wymaga wypełnionego siteDescription i sensownych meta.description stron
(inaczej llms.txt będzie ubogi) — albo pola `aiSummary` (niżej), bogatszego niż
meta description.
Od 1.13:
- pod opisem trafia notka redaktora z **Site Settings → Search & AI → About the site for
AI assistants** (fakty do cytowania, per język) — sekcja „Search & AI” niżej;
- lista nie jest już ucinana na 1000 dokumentów (czytanie partiami; `collectSiteIndex({ limit })`
dalej przycina, jeśli chcesz);
- `llmsRoute` / `llmsFullRoute` z `createContentHelpers` przy włączonym „Under construction”
pokazują tylko otwarte strony (`createLlmsTxtRoute({ getIncludedPaths })` niskopoziomowo);
- odpowiedź ma `Cache-Control` jak sitemap (CDN godzinę), awaryjna — `no-store`.
### buildSummaryField — streszczenie dla AI (bogatsze niż meta)
Pole `aiSummary` (localized textarea) — zwięzły opis strony dla agentów,
@@ -1111,7 +1168,41 @@ Tryby `aiBots`:
Listy botów: `AI_ASSISTANT_BOTS`, `AI_TRAINING_BOTS` (eksportowane; nadpisujesz
przez `aiAssistantAgents` / `aiTrainingAgents`). `Next` akceptuje `rules` jako
tablicę — przy aktywnych botach AI zwracana jest tablica reguł.
tablicę — przy aktywnych botach AI zwracana jest tablica reguł. 1.13 dopisało
asystentów `Claude-User`, `MistralAI-User`, `DuckAssistBot`.
Wyjątki per bot — `aiBotRules` wygrywa z `aiBots`: bot z listy wychodzi ze swojej grupy
i dostaje własną regułę (można dopisać bota spoza list):
```ts
buildRobots({
baseUrl,
aiBots: 'block-training',
aiBotRules: [
{ userAgent: 'GPTBot', access: 'allow' }, // trening OpenAI jednak tak
{ userAgent: 'Bytespider', access: 'disallow' },
],
})
```
### Boty AI z panelu — getRobots (1.13)
Redaktor ustawia politykę i wyjątki w **Site Settings → Search & AI → AI crawlers**.
Żeby robots.txt je czytał, zamień `robots` na `getRobots` (async, czyta Site Settings
per żądanie):
```ts
// app/robots.ts
export { getRobots as default } from '@/lib/content'
export const dynamic = 'force-dynamic'
```
- Polityka „As set by the developer” (domyślna) = to, co w `createContentHelpers({ robots })`.
- Wyjątki z panelu dochodzą do `robots.aiBotRules` z kodu (panel na końcu, więc wygrywa).
- User agent z panelu: jeden token (`[\w\-.*/]`), bez spacji i nowych linii — wpis
„Bot\nDisallow: /” jest odrzucany, nie wstrzyknie reguły.
- Baza niedostępna → opcje z kodu. `IPAL_NOINDEX=1` dalej wygrywa ze wszystkim.
- `robots` (sync) zostaje bez zmian — ignoruje panel.
## Sitemap — czytelny w przeglądarce, zero plików w projekcie
@@ -1154,6 +1245,66 @@ Dwa sitemapy pod różnymi ścieżkami mylą crawlery. Wybierz jeden:
Oba tak samo dobre dla Google — to kwestia czytelności dla człowieka, nie SEO.
## Search & AI — weryfikacja Search Console, boty AI, notka llms.txt (1.13)
Zakładka **Site Settings → Search & AI** (włączona domyślnie; puste pola nic nie
zmieniają; `ipalKit({ seo: { …, searchSettings: false } })` ją usuwa; funkcja
`searchSettings: (fields) => fields` dostaje pola pluginu i zwraca własne — dodaj, usuń,
zmień etykiety; nazwy `searchVerification` / `aiCrawlers` / `llmsIntro` czytają helpery):
| Pole | Gdzie trafia |
|---|---|
| `searchVerification.google` | `<meta name="google-site-verification">` na każdej stronie |
| `searchVerification.bing` | `<meta name="msvalidate.01">` (Bing Webmaster — indeks Binga zasila ChatGPT Search i Copilot) |
| `searchVerification.yandex` | `<meta name="yandex-verification">` |
| `aiCrawlers.policy`, `aiCrawlers.rules` | robots.txt przez `getRobots` (wyżej) |
| `llmsIntro` (per język) | `/llms.txt` pod opisem strony |
Weryfikacja: redaktor wkleja sam kod **albo cały tag** `<meta … content="…">` z Search
Console — zapisuje się tylko kod; coś, co nie jest prostym tokenem, jest odrzucane
(wartość ląduje w `<head>` każdej strony). `generatePageMetadata` / `createPageMetadata`
dodają `verification` same — zero kodu w projekcie. Własny generator:
`verificationFrom(settings)` → `Metadata.verification`; robots: `robotsOptionsFrom(settings)`.
**Domain verification by DNS (recommended)** — a TXT record at the registrar. It needs
nothing from the plugin: leave the verification fields empty, and nothing warns. The
fields are only for URL-prefix verification (HTML tag).
Po wklejeniu kodu: Search Console → Zweryfikuj. Strona musi być zbudowana dynamicznie
albo po rewalidacji (ISR), żeby nowy tag był w HTML. Weryfikacja DNS dalej działa
niezależnie — pola zostaw puste.
Migracja: nowe kolumny w `site_settings` — projekt na Postgresie generuje migrację
(`payload migrate:create`) jak przy każdej aktualizacji z nowymi polami.
### Search Console API (dane w panelu) — nie wbudowane
Kliknięcia/zapytania z Search Console w adminie wymagają konta usługi Google (JSON z
kluczem prywatnym) dodanego jako użytkownik w usłudze GSC, i biblioteki `googleapis`
albo podpisu JWT. Plugin tego nie robi (decyzja: weryfikacja domeny, dane w samej Search Console).
## GEO — co plugin rozumie przez „widoczność w AI” (założenia)
GEO (generative engine optimization) = strona jest **znaleziona, przeczytana i
zacytowana** przez asystentów AI (ChatGPT, Claude, Perplexity, Gemini, Copilot). Plugin
przyjmuje, że realnie działają cztery rzeczy — nie ma ukrytych „rankingów AI”:
1. **Dostęp** — bot AI może pobrać stronę: robots.txt z jawnymi regułami (`aiBots`,
panel), brak blokady w CDN/WAF (tego plugin nie widzi — sprawdź Cloudflare
„Block AI bots”). Asystent (pobiera na żądanie użytkownika) ≠ crawler treningowy.
2. **Indeks, z którego asystent szuka** — Bing (ChatGPT Search, Copilot) → IndexNow +
weryfikacja Bing; Google (AI Overviews, Gemini) → sitemap + Search Console.
3. **Czytelna treść** — HTML renderowany na serwerze, Markdown (`/md/…`, `Link
rel=alternate`), `llms.txt` / `llms-full.txt` jako spis i pełna treść. `llms.txt` to
konwencja (llmstxt.org), nie standard — nic nie szkodzi, nie obiecuje ruchu.
4. **Sygnały do cytowania** — jednoznaczne fakty: Organization/LocalBusiness z `sameAs`,
`dateModified`/`datePublished` (Article, WebPage), okruszki, FAQ, `speakable`,
`aiSummary`, notka `llmsIntro` (kto, co, gdzie, od kiedy — zdania, które da się
zacytować bez kontekstu).
Plugin NIE: generuje treści „pod AI”, ukrywa treści przed ludźmi, serwuje botom AI innej
wersji niż ludziom (cloaking) ani mierzy cytowań (brak publicznego API).
## JsonLdGraph — opakowanie @graph (bez modelu firmy)
Plugin dostarcza klocki Schema.org (buildWebSiteJsonLd, buildOrganizationJsonLd,
@@ -1255,7 +1406,8 @@ Dopełnia Markdown/llms: asystent łatwiej wyciąga kluczową treść strony.
obsługuje IndexNow — dla niego sitemap.
Trasa klucza z `lib/content`: `export { indexNowKeyRoute as GET } from '@/lib/content'`.
Ręcznie (np. import treści skryptem): `submitToIndexNow({ payload, urls })` (klucz: `getIndexNowKey(payload)`)
— nigdy nie rzuca, tylko loguje.
— nigdy nie rzuca, tylko loguje. Z `IPAL_NOINDEX=1` (staging) nic nie wysyła, nawet przy
`NODE_ENV=production` (1.13).
- **llms.txt / llms-full.txt** obejmują wpisy kolekcji treści (`content`) i wszystkie języki; MCP
`list_pages` też. Wspólne źródło: `collectSiteIndex`.