1449 lines
66 KiB
Markdown
1449 lines
66 KiB
Markdown
# seo
|
||
|
||
Wires `@payloadcms/plugin-seo` (meta fields in collections) and adds a logic layer:
|
||
title composition, Next.js `Metadata` with canonical and hreflang,
|
||
auto-fill of empty meta from the document content.
|
||
|
||
## Dependency
|
||
|
||
Add to `dependencies` (pinned to the payload version):
|
||
|
||
```json
|
||
"dependencies": { "@payloadcms/plugin-seo": "3.84.1" }
|
||
```
|
||
|
||
After wiring, run `pnpm payload generate:importmap` — the SEO fields are admin
|
||
components and do not render without the importMap.
|
||
|
||
## Config (payload.config.ts)
|
||
|
||
```ts
|
||
ipalKit({
|
||
seo: {
|
||
collections: ['pages', 'posts'], // which collections get meta
|
||
// generateTitle: ({ doc }) => `${doc.title}`, // optional
|
||
// generateDescription: ({ doc }) => doc.excerpt ?? '',
|
||
// fields: [...], // extra fields in the SEO group
|
||
// autoFill: { title: 'title', description: 'excerpt' }, // auto-fill mapping
|
||
// autoFill: { content: 'blocks', descriptionLength: 155 }, // description from another blocks field
|
||
// autoFill: false, // turn off auto-fill
|
||
// descriptionCheck: { settingsSlug: 'site-settings', siteDescriptionField: 'siteDescription' },
|
||
// descriptionCheck: false, // no hint under the description
|
||
// uploadsCollection: 'images', // meta image upload collection (default 'media')
|
||
},
|
||
})
|
||
```
|
||
|
||
Adds an **SEO** tab to the listed collections: title, description, image,
|
||
titleOverride. Auto-fill: a `beforeChange` hook fills an empty `meta.title` from a
|
||
document field (default `title`), and an empty `meta.description` from the
|
||
`autoFill.description` field (if given), otherwise from the page content (`layout`
|
||
blocks → the first paragraphs without headings, whole sentences up to ~155 characters).
|
||
It never overwrites what the editor typed by hand; on a partial save (REST PATCH,
|
||
`payload.update` with a few fields) it reads the stored description from the document.
|
||
|
||
A script that must save exactly what it sets (data migration, filling fields on
|
||
production): `payload.update({ …, context: { [SKIP_AUTO_FILL]: true } })` — `SKIP_AUTO_FILL`
|
||
(`'ipalSkipAutoFill'`) from `@intecion/ipal-kit` turns off meta and `aiSummary` auto-fill for
|
||
that save (1.12.2).
|
||
|
||
Under the description field in the SEO tab there is a hint (`MetaDescriptionCheck`, `/admin`):
|
||
the description is empty, the same as `siteDescription` from Site settings, or the same as in
|
||
another document of the collection. It only informs — it does not block saving. Length is shown
|
||
by the plugin-seo counter.
|
||
|
||
The tab is built by `injectSeoTabs`, not by plugin-seo's `tabbedUI` —
|
||
that one merges tabs by looking at the collection's first field and breaks when there
|
||
are other fields there already (slug, roles), leaving an empty SEO tab.
|
||
|
||
## Titles — configured from the panel
|
||
|
||
No code, per site (Site settings → General):
|
||
|
||
- **Title Order** — `Page first` (O nas | Acme) or `Site first` (Acme | O nas)
|
||
- **Title Separator** — `|` `–` `-` `·` `/`
|
||
|
||
Per page (SEO tab):
|
||
|
||
- **Exact page title** — the typed text goes to the browser tab verbatim, ignoring both
|
||
settings above. Use it for the home page, where composition would give "Acme | Acme".
|
||
|
||
Default: `Title | Site name`.
|
||
|
||
### Where the "Title" comes from (source priority)
|
||
|
||
The page title (the part before the site name) comes from, in order:
|
||
|
||
1. **titleOverride** — if filled, it is the whole title (no composition).
|
||
2. **meta.title** — the SEO title typed in the SEO tab.
|
||
3. **page.title** — the document name (e.g. "Sprzątanie biur"), when meta.title is empty.
|
||
|
||
Point 3 (fallback to the page name) works in two complementary ways:
|
||
|
||
- **buildAutoFillMetaHook** (on SAVE) — fills an empty `meta.title` from the document
|
||
field (`title`). If wired into the collections, meta.title is never empty.
|
||
- **pageTitle in buildMetadata** (on RENDER) — if meta.title is still empty
|
||
(e.g. auto-fill not wired), it uses `page.title`. A second line of defence.
|
||
|
||
Result: a page without an SEO title still shows its name in the browser tab, not an
|
||
empty title or just the siteName.
|
||
|
||
> **Note — "Strona Główna" in the title:** if the home page document is named
|
||
> "Strona Główna" (and auto-fill copied it to meta.title), the title comes out as
|
||
> "Name – Strona Główna" — useless for SEO. Fix: set **titleOverride**
|
||
> for the home page (e.g. "Firma X – Usługa Miasto"), or change meta.title to
|
||
> something with keywords. The page.title fallback does not help, because the problem is
|
||
> the name itself, not a missing title.
|
||
|
||
## Front — generatePageMetadata (recommended)
|
||
|
||
From `createContentHelpers` (lib/content) — it shares the request cache with the layout and
|
||
the page component: **one** SiteSettings read and **one** `resolveRoute`
|
||
per request, instead of separate queries in metadata and in the page:
|
||
|
||
```ts
|
||
// app/(frontend)/[locale]/[[...slug]]/page.tsx
|
||
import { generatePageMetadata } from '@/lib/content'
|
||
|
||
export async function generateMetadata({ params }): Promise<Metadata> {
|
||
const { locale, slug } = await params
|
||
return generatePageMetadata(locale, slug) // paginated archive: (locale, slug, page)
|
||
}
|
||
```
|
||
|
||
Requires `i18n` in `createContentHelpers`. Under the hood it is `createPageMetadata` with
|
||
injected cached loaders — everything below applies to it too.
|
||
|
||
## createPageMetadata (low level)
|
||
|
||
When you do not use `createContentHelpers` or the route has its own conventions. It knows
|
||
the plugin conventions (pages collection, SiteSettings, System pages, meta group):
|
||
|
||
```ts
|
||
// app/(frontend)/[locale]/[[...slug]]/page.tsx
|
||
import { createPageMetadata } from '@intecion/ipal-kit'
|
||
import { i18nConfig } from '@/i18n.config'
|
||
|
||
const pageMetadata = createPageMetadata({
|
||
config: i18nConfig,
|
||
baseUrl: process.env.NEXT_PUBLIC_SERVER_URL,
|
||
// collection: 'pages', // default
|
||
// settingsSlug: 'site-settings', // default
|
||
// siteNameField: 'siteName', // default
|
||
})
|
||
|
||
export async function generateMetadata({ params }): Promise<Metadata> {
|
||
const { locale, slug } = await params
|
||
return pageMetadata({ payload: await getPayload({ config }), locale, slug })
|
||
}
|
||
```
|
||
|
||
The wrapper is required: Next calls `generateMetadata({ params })` without payload, and
|
||
the plugin never calls `getPayload` itself. The `loaders: { getSettings,
|
||
resolveRoute }` option lets you pass your own cached functions (that is what `generatePageMetadata` does).
|
||
|
||
Handles: title (order/separator/override from the panel), description, canonical,
|
||
hreflang for all locales, OG, home collapsed to `/pl` (home slug read from
|
||
System pages).
|
||
|
||
Without `NEXT_PUBLIC_SERVER_URL`, canonical and hreflang are relative (`/pl` instead of
|
||
`https://…/pl`).
|
||
|
||
## Front — createMetadataGenerator
|
||
|
||
For routes outside the conventions: another collection (blog), custom image logic, another
|
||
global. The project supplies the resolvers.
|
||
|
||
```ts
|
||
import { createMetadataGenerator } from '@intecion/ipal-kit'
|
||
|
||
const generate = createMetadataGenerator({
|
||
config: i18nConfig,
|
||
baseUrl: process.env.NEXT_PUBLIC_SERVER_URL,
|
||
homeSlug: 'homepage',
|
||
|
||
resolveDocument: async ({ payload, params, locale }) => {
|
||
const slug = (params.slug as string[])?.join('/')
|
||
|
||
// meta MUST come in a specific locale (strings), and slug as a map
|
||
// locale→value (hreflang) — these are two different reads.
|
||
const found = await payload.find({
|
||
collection: 'posts',
|
||
where: { slug: { equals: slug } },
|
||
locale,
|
||
depth: 1,
|
||
limit: 1,
|
||
})
|
||
const doc = found.docs[0]
|
||
if (!doc) return null
|
||
|
||
const allLocales = await payload.findByID({
|
||
collection: 'posts',
|
||
id: doc.id,
|
||
locale: 'all',
|
||
depth: 0,
|
||
})
|
||
|
||
return { ...doc, slug: allLocales.slug }
|
||
},
|
||
|
||
resolveSiteName: async ({ payload, locale }) =>
|
||
(await getSiteSettings(payload, { locale })).siteName ?? null,
|
||
resolveImageUrl: async ({ doc }) => doc.meta?.image?.url ?? null,
|
||
})
|
||
|
||
export async function generateMetadata({ params }) {
|
||
const { locale, slug } = await params
|
||
return generate({ payload: await getPayload({ config }), params: { slug }, locale })
|
||
}
|
||
```
|
||
|
||
**Trap:** a single read with `locale: 'all'` looks tempting, but then
|
||
**every** localized field is a map — `meta.title` too. Title composition
|
||
gets an object instead of a string and fails with `pageTitle?.trim is not a function`.
|
||
|
||
Next runs `generateMetadata` and the page component independently — without React
|
||
`cache()` around these reads, every request queries the database twice.
|
||
|
||
## Front — buildMetadata directly
|
||
|
||
When you want full control:
|
||
|
||
```ts
|
||
import { buildMetadata, getLocalizedSlugs } from '@intecion/ipal-kit'
|
||
|
||
return buildMetadata({
|
||
meta: doc.meta, // from plugin-seo
|
||
siteName: settings.siteName,
|
||
imageUrl: '/og.png',
|
||
locale: 'pl',
|
||
slugs: getLocalizedSlugs({ slugField: docAllLocales.slug, config }),
|
||
config,
|
||
baseUrl: 'https://example.com',
|
||
separator: ' – ', // optional
|
||
order: 'site-first', // optional
|
||
homeSlug: 'homepage',
|
||
})
|
||
// → { title, description, openGraph, alternates: { canonical, languages } }
|
||
```
|
||
|
||
## Helpers
|
||
|
||
```ts
|
||
import { composeTitle, buildHreflangAlternates } from '@intecion/ipal-kit'
|
||
|
||
composeTitle({ pageTitle: 'O nas', siteName: 'Acme' })
|
||
// 'O nas | Acme'
|
||
composeTitle({ pageTitle: 'O nas', siteName: 'Acme', separator: ' – ', order: 'site-first' })
|
||
// 'Acme – O nas'
|
||
|
||
buildHreflangAlternates({ slugs, config, baseUrl }) // { pl: '...', en: '...' }
|
||
```
|
||
|
||
## Lower-level helpers
|
||
|
||
`createPageMetadata` is made of smaller, testable pieces —
|
||
exported in case you build your own metadata generator:
|
||
|
||
```ts
|
||
import { readSiteMetaConfig, slugsAcrossLocales } from '@intecion/ipal-kit'
|
||
|
||
// site name, separator (padded), order, homeSlug — from SiteSettings
|
||
const site = await readSiteMetaConfig({ payload, locale })
|
||
|
||
// the document slug in all locales — a map for hreflang
|
||
const slugs = await slugsAcrossLocales({ payload, collection: 'pages', id, config })
|
||
```
|
||
|
||
`slugsAcrossLocales` makes a separate query with `locale: 'all'` — because that mode
|
||
turns EVERY localized field into a map, which is good for the slug and bad for the
|
||
rest (a map in title would break title composition). So it reads only the slug,
|
||
depth 0.
|
||
|
||
## Sitemap and robots.txt
|
||
|
||
The plugin builds the sitemap with hreflang per URL — the same builders as the metadata, so
|
||
it cannot drift from what the pages serve. The handlers are ready in
|
||
`createContentHelpers`; the project re-exports them in one line.
|
||
|
||
```ts
|
||
// src/lib/content.ts
|
||
export const { /* ... */, sitemap, robots } = createContentHelpers({
|
||
config,
|
||
content: contentConfig,
|
||
i18n: i18nConfig, // required for sitemap (hreflang)
|
||
baseUrl: process.env.NEXT_PUBLIC_SERVER_URL,
|
||
})
|
||
```
|
||
|
||
```ts
|
||
// app/sitemap.ts
|
||
export { sitemap as default } from '@/lib/content'
|
||
export const dynamic = 'force-dynamic' // generate at runtime, not at build
|
||
|
||
// app/robots.ts
|
||
export { robots as default } from '@/lib/content'
|
||
```
|
||
|
||
Next generates `/sitemap.xml` and `/robots.txt` from these. This cannot be hidden
|
||
entirely in the plugin — Next creates these routes only from files in `app/`; it scans
|
||
the project directory, not node_modules. But a re-export is the minimum: all the
|
||
logic is in the plugin.
|
||
|
||
> **Container deploy (Coolify, CI builds) — IMPORTANT:** `export const
|
||
> dynamic = 'force-dynamic'` in `app/sitemap.ts` is REQUIRED. Without it Next
|
||
> treats the sitemap as static and prerenders it during `next build` — which
|
||
> calls Payload → the database. The build container usually has no access to the
|
||
> deployment network, so the database connection fails (`ENOTFOUND`) and the build crashes. With
|
||
> `force-dynamic` the sitemap is generated at runtime, when the database is available.
|
||
> (The plugin also catches the database error and returns an empty sitemap instead of crashing the build
|
||
> — but `force-dynamic` is the right fix, not relying on the fallback.)
|
||
> Optionally `export const revalidate = 3600` — cache the sitemap for an hour.
|
||
> Other hosts: the same applies to any host that builds without database access.
|
||
|
||
What the sitemap contains:
|
||
- every page and blog post, URL in the default locale
|
||
- `alternates.languages` → Next renders `<xhtml:link rel="alternate" hreflang>`
|
||
per URL (Google reads this for multiple languages; a plain sitemap does not have it)
|
||
- `lastModified` from the document's real `updatedAt`
|
||
- blog posts with the archive prefix (`/pl/artykuly/moj-post`)
|
||
|
||
Skips: drafts (`_status !== 'published'`) and documents with `meta.noindex`. When
|
||
**Site settings → Maintenance** is on — everything except the pages that
|
||
stay open (home page + "Pages still available"), because the rest redirects to the
|
||
notice and a crawler would index that instead of the content. `llms.txt` does the same.
|
||
|
||
Large collections (1.13): documents are read in batches of 500 (`SITEMAP_BATCH_SIZE`), only
|
||
published ones (`where _status` for a collection with drafts) and only the needed fields
|
||
(`select`: slug, updatedAt, noindex, meta). A custom `sitemapImages` may read any
|
||
field, so then the whole document is read (`buildSitemapEntries({ select: true })`
|
||
forces select).
|
||
|
||
Low level (your own route instead of the factory handler):
|
||
|
||
```ts
|
||
import { buildSitemapEntries, buildRobots } from '@intecion/ipal-kit'
|
||
|
||
const entries = await buildSitemapEntries({
|
||
payload, config: i18nConfig, baseUrl, content: contentConfig,
|
||
})
|
||
```
|
||
|
||
### Large site — sitemap index, cache, errors (1.13)
|
||
|
||
`sitemapRoute` (`createSitemapRouteHandler`) splits the sitemap by itself when there are more URLs
|
||
than `maxUrls` (default 10 000 — the protocol allows 50 000 / 50 MB, but hreflang turns
|
||
each URL into several lines):
|
||
|
||
- `/sitemap.xml` → `<sitemapindex>` with parts `/sitemap.xml?part=1`, `?part=2`…;
|
||
each part has `lastmod` = the newest `lastmod` of its URLs.
|
||
- robots.txt and Search Console keep using the single `/sitemap.xml` address.
|
||
- A non-existent part → 404.
|
||
|
||
| Option | Default | What it does |
|
||
|---|---|---|
|
||
| `maxUrls` | `10000` | URLs in one file; above that — index + parts |
|
||
| `cacheControl` | `public, max-age=0, s-maxage=3600, stale-while-revalidate=86400` | the CDN keeps it for an hour, the browser checks every time; `false` = no header |
|
||
| `memoSeconds` | `300` | how many seconds the process keeps the built list (the index and parts do not rebuild it); `0` = off |
|
||
|
||
```ts
|
||
createContentHelpers({ …, sitemapOptions: { maxUrls: 5000, memoSeconds: 0 } }) // sitemapRoute
|
||
createSitemapRouteHandler(sitemap, { maxUrls: 5000, memoSeconds: 0 }) // your own route
|
||
```
|
||
|
||
The project has the last word — `sitemapEntries` receives the plugin's entries and returns the list to
|
||
publish (add your own routes' addresses, remove entries, set `priority`):
|
||
|
||
```ts
|
||
createContentHelpers({ …,
|
||
sitemapEntries: (entries) => [...entries, { url: `${origin}/kalkulator`, lastModified: new Date() }],
|
||
})
|
||
```
|
||
|
||
Turn off the "Under construction" filter in the sitemap and llms.txt with `underConstructionSeo: false`.
|
||
|
||
A database error at runtime → **503 + `Retry-After: 300`** (the crawler comes back), not an empty sitemap
|
||
with 200 ("the site has no pages"). An empty response and an error are never served from cache.
|
||
Exception: `next build` (`NEXT_PHASE=phase-production-build`) still gets an empty,
|
||
valid sitemap, so a build without a database does not fail. `sitemap()` from `createContentHelpers`
|
||
also throws at runtime (it used to return `[]`).
|
||
|
||
`app/sitemap.ts` (MetadataRoute) does not split — for a large site use `sitemapRoute`.
|
||
Your own route: `buildSitemapIndexXml([{ url, lastModified }], { cssUrl })` builds just the index.
|
||
|
||
## Favicon in Google + Organization (branding in search)
|
||
|
||
The favicon and structured data affect how the site looks in Google results.
|
||
The plugin generates both from the panel — the project only wires them into the root layout.
|
||
|
||
### Favicon — format: PNG, not SVG (important)
|
||
|
||
**For Google use PNG (≥48×48), not SVG.** Verified: Google reliably
|
||
supports PNG and ICO, but **SVG in Google results is unreliable** — it often shows a
|
||
globe even though the favicon renders fine in the browser tab. Google's official
|
||
documentation does not list SVG. If you care about the favicon in search
|
||
— upload a PNG.
|
||
|
||
- **PNG ≥48×48** (ideally 96 or 192), square → works in Google ✓
|
||
- **SVG** → works in the browser, but a globe in Google (unreliable) ✗
|
||
- The favicon field validation WARNS when you upload an SVG (so you know search
|
||
needs a PNG).
|
||
|
||
### Favicon — why it did not show
|
||
|
||
Google has hard requirements: `<link rel="icon">` in `<head>`, square, **≥48×48px**,
|
||
a stable URL. When projects rendered the favicon "their own way", it was often too small, wrongly
|
||
tagged or missing from head → Google did not show it. The plugin now does it
|
||
correctly.
|
||
|
||
### Wiring the favicon (root layout)
|
||
|
||
The favicon is GLOBAL (the same everywhere) — wire it ONCE in the root layout, not per page:
|
||
|
||
```tsx
|
||
// app/(frontend)/[locale]/layout.tsx
|
||
import type { Metadata } from 'next'
|
||
import { buildIconsMetadata } from '@intecion/ipal-kit'
|
||
import { getSettings } from '@/lib/content' // from createContentHelpers
|
||
|
||
export async function generateMetadata({ params }): Promise<Metadata> {
|
||
const { locale } = await params
|
||
const settings = await getSettings(locale)
|
||
return buildIconsMetadata(settings.favicon) // from the favicon field (panel)
|
||
}
|
||
```
|
||
|
||
`buildIconsMetadata` generates correct `icons` (favicon + apple-touch) from the
|
||
favicon field. SVG → scales; PNG → should be ≥48×48 (validation warns, see below).
|
||
|
||
### Enforcing the size (validation)
|
||
|
||
The favicon field in SiteSettings has the `validateFaviconField` validation — it warns
|
||
the editor on save if the favicon is <48×48 or not square. The editor
|
||
sees a warning instead of silently uploading a favicon Google will not show.
|
||
|
||
### Organization JSON-LD (branding)
|
||
|
||
Helps Google link the site to the brand (name, logo) — better display in
|
||
results, logo in the knowledge panel.
|
||
|
||
```tsx
|
||
// root layout — ONCE (Organization is global)
|
||
import { buildOrganizationJsonLd } from '@intecion/ipal-kit'
|
||
|
||
const jsonLd = buildOrganizationJsonLd({
|
||
name: settings.siteName,
|
||
url: process.env.NEXT_PUBLIC_SERVER_URL!,
|
||
logo: settings.logo,
|
||
sameAs: settings.socialLinks, // optional: social profiles
|
||
})
|
||
|
||
// in the layout JSX — always through JsonLdGraph (escapes `<`, builds @graph):
|
||
import { JsonLdGraph } from '@intecion/ipal-kit/rsc'
|
||
<JsonLdGraph schemas={[jsonLd]} />
|
||
```
|
||
|
||
Data from the panel (siteName, logo) — nothing hard-coded.
|
||
|
||
### After deployment — be patient with Google
|
||
|
||
Google **caches the favicon separately and slowly** (days, sometimes weeks). After correct
|
||
wiring the favicon will not appear immediately — Googlebot has to revisit
|
||
the home page. To speed it up: Search Console → request reindexing of the
|
||
home page. Also check that `/` does not block Googlebot (robots) and that the
|
||
favicon URL is public (not behind auth).
|
||
|
||
### Check
|
||
|
||
1. Open the site → DevTools → Elements → `<head>` → look for `<link rel="icon">`
|
||
with the correct URL.
|
||
2. Open the favicon URL itself in the browser — the image shows, ≥48×48.
|
||
3. Rich Results Test (Google) — paste the page URL, check Organization.
|
||
4. Search Console → request reindexing of the home page.
|
||
|
||
## Manual SEO/PWA extensions (manifest etc.) — from the panel, NOT hard-coded
|
||
|
||
Some SEO/PWA things are so project-specific and one-off that the plugin
|
||
does not provide them (that would be over-engineering). You do them in the project — BUT
|
||
correctly: reading from the panel/env, not hard-coding client values.
|
||
|
||
> **Rule:** even when you do something by hand in the project, read the data (name, colours,
|
||
> description, logo) from the panel (SiteSettings) or env. A hard-coded client name/colour
|
||
> = anti-pattern (see AGENT.md §2). An "R Custom Cars" manifest with
|
||
> hard-coded values works for one client only.
|
||
|
||
### Web App Manifest (PWA) — how to do it RIGHT
|
||
|
||
Main rule: **no data → SKIP the field, do NOT hard-code a value.** Is a manifest
|
||
valid without `name`? No — but a manifest without a name is better than one with another
|
||
client's name in a fallback. A fallback with a client name/colour is a hidden hard-code.
|
||
|
||
> **Recommended (current): `createManifestHandler`** — the same without hand-written code,
|
||
> with try/catch for a missing database at build time:
|
||
> ```ts
|
||
> // app/manifest.ts — usually: export { manifest as default } from '@/lib/content'
|
||
> import { createManifestHandler } from '@intecion/ipal-kit'
|
||
> import { getCachedPayload } from '@/lib/content'
|
||
> import { i18nConfig } from '@/i18n.config'
|
||
> export const dynamic = 'force-dynamic'
|
||
> export default createManifestHandler({ getCachedPayload, config: i18nConfig })
|
||
> ```
|
||
> The manual variant below — when the manifest needs fields outside the panel.
|
||
|
||
```ts
|
||
// app/manifest.ts
|
||
import type { MetadataRoute } from 'next'
|
||
import { getCachedPayload } from '@/lib/content'
|
||
import { getSiteSettings } from '@intecion/ipal-kit'
|
||
import { i18nConfig } from '@/i18n.config'
|
||
import type { SiteSetting } from '@/payload-types'
|
||
|
||
export default async function manifest(): Promise<MetadataRoute.Manifest> {
|
||
const payload = await getCachedPayload()
|
||
const settings = await getSiteSettings<SiteSetting>(payload, {
|
||
locale: i18nConfig.defaultLocale as never,
|
||
})
|
||
|
||
const siteName = settings?.siteName?.trim()
|
||
|
||
// Icon from the panel (favicon → logo). For PNG give a SPECIFIC size from the media
|
||
// (not 'any' — 'any' is for SVG only). No icon → skip the icons field.
|
||
const icon = settings?.favicon ?? settings?.logo
|
||
const iconEntry =
|
||
typeof icon === 'object' && icon?.url
|
||
? (() => {
|
||
const isSvg = icon.mimeType === 'image/svg+xml' || icon.url.endsWith('.svg')
|
||
const size =
|
||
typeof icon.width === 'number' && typeof icon.height === 'number'
|
||
? `${Math.min(icon.width, icon.height)}x${Math.min(icon.width, icon.height)}`
|
||
: '512x512'
|
||
return {
|
||
src: icon.url,
|
||
type: icon.mimeType ?? 'image/png',
|
||
sizes: isSvg ? 'any' : size, // 'any' for SVG only
|
||
}
|
||
})()
|
||
: undefined
|
||
|
||
// Build ONLY from what exists. Missing field → it is not in the manifest (instead of
|
||
// a hard-coded fallback). start_url from the config, not a hard-coded '/pl'.
|
||
return {
|
||
...(siteName ? { name: siteName, short_name: siteName } : {}),
|
||
start_url: `/${i18nConfig.defaultLocale}`,
|
||
display: 'standalone',
|
||
...(iconEntry ? { icons: [iconEntry] } : {}),
|
||
// theme_color / background_color / description — ONLY if you add fields in the
|
||
// panel and read them. Do NOT hard-code '#0e1e24' or a client description.
|
||
}
|
||
}
|
||
```
|
||
|
||
**Key differences from a common agent mistake:**
|
||
- **No fallback with a client name** — `siteName` empty → skip `name`, do not
|
||
insert "Kancelaria X" hard-coded. Another client's name in a fallback = hard-code.
|
||
- **PNG gets a specific `sizes`** from the media dimensions (not `sizes: 'any'` — that is
|
||
the same mistake as with the favicon; `any` for SVG only).
|
||
- **No `catch` block with hard-coded values** — if you worry about an error, wrap just
|
||
`getSiteSettings` and on error return a minimal manifest (start_url + display),
|
||
WITHOUT a hard-coded name/colours.
|
||
- **start_url from i18nConfig**, not a hard-coded `/pl`.
|
||
|
||
**Contrast — what NOT to do** (real mistakes from projects):
|
||
|
||
```ts
|
||
// WRONG — explicit hard-code (rcustomcars)
|
||
let name = 'R Custom Cars'; short_name: 'RCC'
|
||
background_color: '#08080a', theme_color: '#d4af37'
|
||
icons: [{ src: '/logo/rcc-logo.svg' }] // static path
|
||
|
||
// WRONG — hard-code HIDDEN in a fallback (law firm)
|
||
siteName || 'Kancelaria Adwokacka Adwokat Romuald Kędzierski' // another client's name in ||
|
||
sizes: 'any', type: mimeType // 'any' on PNG = wrong
|
||
catch { return { name: 'Kancelaria...', theme_color: '#0e1e24' } } // hard-code in catch
|
||
```
|
||
|
||
A `|| 'Client Name'` fallback looks innocent, but it is a hard-code — another project
|
||
copies it and shows someone else's name when the panel fails. No data → skip the field.
|
||
|
||
If the client needs theme colours / a description in the manifest — **add the fields**
|
||
`themeColor`, `manifestDescription` in SiteSettings (through the plugin's
|
||
SiteSettingsFields options) and read them from the panel. Then the editor changes them; they are not hard-coded.
|
||
|
||
### Other manual extensions — the same rule
|
||
|
||
Whatever you add by hand (extra meta tags, structured data of a specific
|
||
type, etc.):
|
||
- data from the panel (SiteSettings / page fields) or env
|
||
- nothing hard-coded per client (name, colour, address, domain)
|
||
- if it is universal and repeatable → consider reporting it to the plugin instead of doing it
|
||
by hand (see AGENT.md §2)
|
||
|
||
## CRITICAL: metadata in <head> for Google
|
||
|
||
**The biggest SEO trap in Next.js — it affects EVERY project.** For dynamically
|
||
rendered pages (SSR) Next.js **streams metadata into `<body>`**, not `<head>`,
|
||
and moves it to head with a JS script. Result: canonical, hreflang, title, favicon
|
||
land in body in the raw HTML. Crawlers without JS (Screaming Frog, some bots) see
|
||
them outside head → ignore them → SEO loss.
|
||
|
||
**It is a race condition:** when the database answers quickly, the metadata makes it
|
||
into head; when slower (or a crawler hits many pages at once, loading the database),
|
||
Next closes `</head>` and appends the metadata in `<body>`. That is why a single `curl`
|
||
can show head OK, while a 10-request test shows 5/10 in body. **Test repeatedly.**
|
||
|
||
### MAIN fix — ISR (revalidate) in pages
|
||
|
||
The most effective: **cache the whole page (ISR)**. The page is generated once with a complete
|
||
`<head>`, later requests serve the cache — zero database queries while rendering,
|
||
so the race condition DISAPPEARS (metadata always in head). Bonus: TTFB drops from ~500ms to
|
||
~20ms, the occasional 503s (cold start) go away.
|
||
|
||
```ts
|
||
// app/(frontend)/[locale]/[[...slug]]/page.tsx
|
||
export const revalidate = 3600 // cache 1h, regenerate in the background
|
||
```
|
||
|
||
> **NOTE — ISR and content from the panel:** a page cached for `revalidate` seconds does NOT
|
||
> show editor changes immediately (it waits for revalidation). For rarely changed content
|
||
> that is OK. If the editor must see changes immediately — use **on-demand
|
||
> revalidation**: an `afterChange` hook in the collection → `revalidatePath(path)` (see
|
||
> [hooks.md](./hooks.md)). Or a shorter `revalidate` (e.g. 300 = 5 min). Do NOT combine ISR with
|
||
> `force-dynamic` — they exclude each other.
|
||
|
||
### SECOND fix — remove the explicit <head> from the layout
|
||
|
||
A hard-coded `<head>` in an App Router layout forces head to close early —
|
||
before the page generates its metadata. That pushes metadata into body. Do NOT declare `<head>`:
|
||
|
||
```tsx
|
||
// WRONG — an explicit <head> closes head too early
|
||
<html lang={locale}>
|
||
<head><MediaPreconnect /></head>
|
||
<body>{children}</body>
|
||
</html>
|
||
|
||
// RIGHT — MediaPreconnect in body, React 19 hoists the link to head
|
||
<html lang={locale}>
|
||
<body>
|
||
<MediaPreconnect />
|
||
{children}
|
||
</body>
|
||
</html>
|
||
```
|
||
|
||
React 19 moves `<link rel="preconnect">` to head by itself. An explicit `<head>` is
|
||
unnecessary and harmful (it forces an early close).
|
||
|
||
### THIRD fix — htmlLimitedBots (supplement)
|
||
|
||
You can also force blocking metadata for crawlers (useful when a page
|
||
for some reason cannot be ISR):
|
||
|
||
```ts
|
||
// next.config.ts
|
||
const nextConfig: NextConfig = {
|
||
htmlLimitedBots:
|
||
/Googlebot|Google-InspectionTool|Storebot-Google|Bingbot|Yandex|DuckDuckBot|Baiduspider|Screaming Frog|AhrefsBot|SemrushBot/i,
|
||
}
|
||
```
|
||
|
||
`htmlLimitedBots` turns off streaming for these User-Agents (metadata in head). BUT
|
||
it is weaker than ISR — the page still renders dynamically (database query →
|
||
slower, race risk). **ISR removes the cause, htmlLimitedBots eases the symptom.**
|
||
Best: ISR + no explicit head. htmlLimitedBots as an extra layer.
|
||
|
||
### Symptoms (that you have this problem)
|
||
|
||
- Screaming Frog: "canonical/hreflang/title outside <head>" (on many pages)
|
||
- Search Console: "missing canonical", favicon globe
|
||
- Raw HTML: canonical/title AFTER `</head>`, at the end of body, with an appendChild script
|
||
- 10-request test: some in head, some in body (race condition)
|
||
|
||
### Check — TEST REPEATEDLY (not once)
|
||
|
||
A single `curl` can hit "lucky" timing. Test 10 times:
|
||
|
||
```bash
|
||
# 10 requests as Googlebot — how many have canonical in <head>
|
||
for i in $(seq 1 10); do
|
||
curl -s -A "Googlebot" https://twojadomena.pl/pl/strona | \
|
||
python3 -c "import sys; h=sys.stdin.read(); e=h.find('</head>'); c=h.find('rel=\"canonical\"'); print('head' if 0<c<e else 'BODY')"
|
||
done
|
||
# Goal: 10x 'head'. If some are 'BODY' → race condition, add ISR.
|
||
```
|
||
|
||
Test SUBPAGES too (not only the home page) — the race hits subpages more often.
|
||
DevTools (F12) is NOT suitable for the test — it hoists tags to head automatically,
|
||
showing a falsely correct head. Use `curl` / Ctrl+U (raw source).
|
||
|
||
## Multilingual SEO — hreflang, x-default, root redirect
|
||
|
||
The `/` → `/pl` redirect (locale negotiation) can affect SEO. Key point:
|
||
the plugin generates hreflang, so Google understands that `/pl` and `/en` are language
|
||
versions (not duplicates). But there are nuances.
|
||
|
||
### hreflang + x-default (generated by the plugin)
|
||
|
||
`buildHreflangAlternates` generates `alternates.languages` with an entry per locale
|
||
AND **`x-default`** pointing to the defaultLocale. x-default tells Google: "when
|
||
the user's language/region matches no version, use THIS one" — which covers the
|
||
root case (Googlebot without a language preference). Without x-default Google
|
||
would guess; with it, it gets a clear hint (pl by default).
|
||
|
||
Works automatically through createPageMetadata (canonical + hreflang + x-default).
|
||
|
||
### Root redirect — what to watch
|
||
|
||
- **307 (temporary)** on `/` → `/pl` — the plugin does this. For a conditional redirect
|
||
(depending on negotiation) that is the safe choice. Google follows it anyway.
|
||
- **Accept-Language negotiation** — Googlebot comes with `Accept-Language: en` or
|
||
without it. It may land on `/en`. x-default (→ pl) softens this: Google knows the
|
||
default version is Polish.
|
||
- **The root has no content of its own** — all the weight goes through the redirect to a locale. That is
|
||
normal for i18n sites; hreflang handles it.
|
||
|
||
### Checking multilingual SEO
|
||
|
||
1. Search Console → URL Inspection for `/` — see where Google redirects
|
||
and what it indexes.
|
||
2. Check that `/pl` and `/en` are indexed separately (not as duplicates).
|
||
3. Rich Results / page source → confirm `<link rel="alternate" hreflang="...">`
|
||
with an entry per locale + `hreflang="x-default"`.
|
||
4. Search Console → International Targeting report (if available) — hreflang
|
||
errors.
|
||
|
||
### Common mistakes (do not do this)
|
||
|
||
- No hreflang → Google treats the versions as duplicates (the plugin has it, do not remove it).
|
||
- A hard-coded path map instead of getLocalizedSlugs → hreflang drifts from the database.
|
||
- `noindex` on `/pl` by mistake → it drops out of the index. Check the robots meta.
|
||
- A hard 301 root redirect to one language → you lose negotiation and the other
|
||
version. Keep negotiation + hreflang.
|
||
|
||
## Descriptions in Google — data-nosnippet (footer, contact details)
|
||
|
||
Symptom: under the result and the sitelinks Google shows the address, hours and e-mail from the
|
||
footer instead of the meta description — the same text under every subpage.
|
||
|
||
Cause: Google picks the snippet text itself when it decides it matches the query
|
||
better than the description. For a brand search the contact block "matches", and the footer
|
||
is on every page. A good, unique description does not stop this.
|
||
|
||
Fix: put text repeated on every page in `data-nosnippet`. The page is still
|
||
indexed; Google only does not quote that fragment. It still has the address and hours
|
||
from the `LocalBusiness` JSON-LD.
|
||
|
||
```tsx
|
||
import { NoSnippet } from '@intecion/ipal-kit/rsc' // in a client component: /client
|
||
|
||
<footer>
|
||
<NoSnippet>…address, hours, phone, links…</NoSnippet>
|
||
</footer>
|
||
```
|
||
|
||
- Google honours `data-nosnippet` only on `div`, `section`, `span` — NOT on `footer`,
|
||
`nav`, `aside`. That is why `NoSnippet` renders a `div` (`as="section"` /
|
||
`as="span"`), and the `<footer>` stays outside.
|
||
- Wrap: the footer, the contact bar, a CTA section repeated on every page
|
||
("Umów się na konsultację"). **Never `<main>`** — the snippet should come from it.
|
||
- The plugin's components do this themselves: `CookieBanner`, `LanguageSwitcher`.
|
||
- The effect shows after a recrawl (days–weeks). `ipal-seo-check` warns about a footer without
|
||
`data-nosnippet` and about duplicated descriptions.
|
||
|
||
## Sitelinks — brand search signals
|
||
|
||
Goal: a brand search ("rcustomcars") shows the home page + sub-links
|
||
(sitelinks) with descriptions. Important — **sitelinks CANNOT be forced.** Google
|
||
generates them algorithmically from the site structure, internal linking, clear
|
||
titles and ranking. No code turns them on. The plugin provides SIGNALS that
|
||
raise the chance — not a guarantee.
|
||
|
||
### What really affects sitelinks (in order of weight)
|
||
|
||
1. **Ranking on Google's first page** — without it there are no sitelinks. That is SEO work
|
||
(content, links), not code.
|
||
2. **Clean structure + clear titles** — a logical page hierarchy, descriptive titles
|
||
(not "Strona 1"). See AGENT.md §3.
|
||
3. **Internal linking** — important pages linked from the home page.
|
||
4. **Structured data** (below) — a supporting signal, not a switch.
|
||
5. **Sitemap + robots** — so Google sees all pages at all (see
|
||
below — this is the foundation, check that it works!).
|
||
|
||
### Structured data from the plugin — 3 helpers
|
||
|
||
All emitted as `<script type="application/ld+json">`, data from the panel.
|
||
|
||
**1. WebSite + SearchAction (the biggest real effect)** — can give a sitelinks
|
||
searchbox (a search field under the brand result). ONCE in the root layout:
|
||
```tsx
|
||
import { buildWebSiteJsonLd } from '@intecion/ipal-kit'
|
||
const jsonLd = buildWebSiteJsonLd({
|
||
name: settings.siteName,
|
||
url: baseUrl,
|
||
// ONLY if you have a working search page:
|
||
search: { target: `${baseUrl}/szukaj?q={search_term_string}` },
|
||
})
|
||
```
|
||
Skip `search` if there is no real search — a SearchAction pointing to a
|
||
non-existent page does harm.
|
||
|
||
**2. BreadcrumbList (real effect)** — breadcrumbs in results ("Dom › Usługi › Detailing") + Google understands
|
||
the hierarchy. PER PAGE, from the page's position:
|
||
```tsx
|
||
import { buildBreadcrumbJsonLd } from '@intecion/ipal-kit'
|
||
const jsonLd = buildBreadcrumbJsonLd([
|
||
{ name: homeTitle, url: `${base}/pl` }, // names from page titles in the panel, not from code
|
||
{ name: 'Usługi', url: `${base}/pl/uslugi` },
|
||
{ name: 'Detailing', url: `${base}/pl/uslugi/detailing` },
|
||
])
|
||
```
|
||
Build breadcrumbs from the page's REAL position (resolveRoute / URL path), NOT from a
|
||
hard-coded list.
|
||
|
||
**3. SiteNavigationElement (weaker, cheap)** — navigation as data. ONCE, from the
|
||
same items as the header menu:
|
||
```tsx
|
||
import { buildSiteNavigationJsonLd } from '@intecion/ipal-kit'
|
||
const jsonLd = buildSiteNavigationJsonLd(
|
||
navItems.map(i => ({ name: i.label, url: `${base}${i.href}` }))
|
||
)
|
||
```
|
||
Data from the same source as the visible menu — not a separate hard-coded list.
|
||
|
||
### Real expectations (important)
|
||
|
||
- Structured data **does not guarantee** sitelinks — it is one signal among many.
|
||
- The effect (if any) appears **after weeks**, once Google recrawls and
|
||
the site ranks.
|
||
- The biggest impact comes from **ranking + structure + linking**, not schema. Schema
|
||
helps Google understand, but it does not replace being on the first page.
|
||
- Check: Google Rich Results Test (is the schema valid) + Search Console
|
||
(what Google shows for the brand).
|
||
|
||
### What DEPENDS ON THE PROJECT (wiring duties)
|
||
|
||
The plugin provides helpers — the project MUST wire them and pass data from the panel:
|
||
|
||
- [ ] `buildWebSiteJsonLd` in the root layout (search only if there is a search page)
|
||
- [ ] `buildOrganizationJsonLd` in the root layout (logo, name)
|
||
- [ ] `buildBreadcrumbJsonLd` on subpages (from the real path)
|
||
- [ ] `buildSiteNavigationJsonLd` from the menu items (if there is a header nav)
|
||
- [ ] `app/robots.ts` and `app/sitemap.ts` exposed (see below — without them
|
||
Google does not see the pages!)
|
||
- [ ] Clear, descriptive page titles (not generic)
|
||
- [ ] The footer and repeated contact blocks in `<NoSnippet>` (above: "Descriptions in Google")
|
||
- [ ] A logical hierarchy + internal linking from the home page
|
||
|
||
Data EVERYWHERE from the panel (siteName, nav, logo), never hard-coded.
|
||
|
||
## noindex per page (legal pages, thin pages, search results)
|
||
|
||
Some pages should NOT be in Google's index: policies/terms (they cannibalise
|
||
phrases), pages with parameters, search results. The plugin supports this through the
|
||
`noindex` field in the SEO meta.
|
||
|
||
```ts
|
||
// in the page data (meta): noindex: true
|
||
// buildMetadata automatically adds robots: { index: false, follow: true }
|
||
```
|
||
|
||
`noindex, follow` — the page drops out of the index, but links still pass weight
|
||
(follow). Set it for:
|
||
- privacy policy, terms, cookie policy
|
||
- pages with calculator or filter parameters
|
||
- internal search results
|
||
|
||
The editor ticks `noindex` in the panel (the page's SEO field), the plugin generates the tag.
|
||
Alternatively: add `noindex` to System pages with legal roles automatically.
|
||
|
||
### buildNoindexField — a friendly checkbox in the sidebar
|
||
|
||
One switch in the sidebar. Ticked → the page **automatically** drops out of:
|
||
`sitemap.xml`, `llms.txt`, search, and gets `robots: noindex, follow` —
|
||
with no manual filtering in the project.
|
||
|
||
```ts
|
||
import { buildNoindexField } from '@intecion/ipal-kit'
|
||
|
||
export const Pages: CollectionConfig = {
|
||
fields: [ /* … */ buildNoindexField() ],
|
||
}
|
||
```
|
||
|
||
**The field is top-level (`doc.noindex`), NOT mirrored to `meta.noindex`.**
|
||
Why: plugin-seo's `meta` group declares only title/description/image, so
|
||
Payload **silently strips** any extra key (`meta.noindex`) during sanitisation
|
||
— an earlier version mirrored the value there and it vanished, so noindex pages
|
||
ended up in the sitemap. Now the value lives on the top-level field (which is saved), and
|
||
all kit readers (`buildSitemapEntries`, `buildMetadata`/
|
||
`createPageMetadata`, `buildLlmsTxt`, `searchContent`) check `doc.noindex`
|
||
(and, for backward compatibility, any `meta.noindex`). One field, one
|
||
source of truth, zero glue in the project.
|
||
|
||
Options: `name` (default `'noindex'`), `label`, `description`, `overrides`
|
||
(position, access etc.).
|
||
|
||
> Fixed in 1.7.5 — before (mirror to `meta.noindex`) noindex pages
|
||
> could leak into the sitemap. After updating, `app/sitemap.xml/route.ts`
|
||
> goes back to a clean one-liner, without manual filtering.
|
||
|
||
## robots.txt — blocking parameters (crawl budget)
|
||
|
||
URLs with parameters (`?meter=101-120m2`, `?s=fraza`) waste the crawl budget —
|
||
Google scans dozens of empty variants. Block them in robots — they **are added**
|
||
to the default `/admin` and `/api`:
|
||
|
||
```ts
|
||
// lib/content.ts — the ready robots handler with options
|
||
createContentHelpers({
|
||
config, content, i18n: i18nConfig, baseUrl,
|
||
robots: {
|
||
disallowParams: ['s', 'meter'], // → /*?s=, /*&s=, /*?meter=, /*&meter=
|
||
extraDisallow: ['/koszyk'], // extra paths (optional)
|
||
// aiBots: 'block-training', // see "let AI bots in" below
|
||
},
|
||
})
|
||
|
||
// app/robots.ts
|
||
export { robots as default } from '@/lib/content'
|
||
```
|
||
|
||
Without `createContentHelpers`: `buildRobots({ baseUrl, disallowParams: ['s', 'meter'] })`.
|
||
|
||
| Option | Effect |
|
||
|---|---|
|
||
| `disallowParams` | parameter names → `/*?name=` and `/*&name=` (the parameter does not have to be first) |
|
||
| `extraDisallow` | paths added to the defaults |
|
||
| `adminRoute` | the panel path to block (default `/admin`); `false` = do not list it (hidden panel — see security.md) |
|
||
| `disallow` | the **full** list — replaces the defaults (the old way; easy to lose `/admin`) |
|
||
|
||
**Do not block `page`** — archive pages `?page=2` are real pages with
|
||
a canonical to themselves. Real case from an audit: 55 non-indexed calculator pages
|
||
(`?meter=`) — blocking them in robots would have prevented that.
|
||
|
||
## Local SEO — LocalBusiness, Service, FAQPage (structured data)
|
||
|
||
For local businesses (service + city) — three schemas that raise visibility
|
||
in local results and rich results.
|
||
|
||
**LocalBusiness (map pack, local results)** — ONCE in the root layout, from the company global:
|
||
```ts
|
||
import { buildLocalBusinessJsonLd } from '@intecion/ipal-kit'
|
||
const jsonLd = buildLocalBusinessJsonLd({
|
||
name: company.name, url: baseUrl, telephone: company.phone,
|
||
address: company.address, openingHours: company.hours,
|
||
geo: company.geo, priceRange: '$$',
|
||
})
|
||
```
|
||
The most important one for "service + city". For a specific type (Dentist, Plumber)
|
||
override `@type`.
|
||
|
||
**Service (what the page offers)** — per service page:
|
||
```ts
|
||
import { buildServiceJsonLd } from '@intecion/ipal-kit'
|
||
const jsonLd = buildServiceJsonLd({
|
||
name: 'Sprzątanie biur', providerName: company.name,
|
||
url: pageUrl, areaServed: 'Wrocław',
|
||
})
|
||
```
|
||
|
||
**FAQPage (FAQ rich results)** — per page with an FAQ, from the FAQ block in the panel:
|
||
```ts
|
||
import { buildFaqJsonLd } from '@intecion/ipal-kit'
|
||
const jsonLd = buildFaqJsonLd(
|
||
faqBlock.items.map(i => ({ question: i.question, answer: i.answer }))
|
||
)
|
||
```
|
||
IMPORTANT: the Q&A must match the visible page content (Google flags a mismatch).
|
||
Do not invent questions that are not on the page.
|
||
|
||
All of them: data from the panel (company, blocks), rendered through `<JsonLdGraph>` — never a hand-written `<script type="application/ld+json">`.
|
||
|
||
## Multilingual home page — homeSlug per language (fixed in 1.2)
|
||
|
||
When the home page has DIFFERENT slugs per language (pl: `strona-glowna`, de: `startseite`),
|
||
the plugin supports a homeSlug map — each language collapses to its own root (`/pl`,
|
||
`/de`), and hreflang points correctly (not to `/de/startseite`).
|
||
|
||
- **readSiteMetaConfig** reads the homepage slug per language (`locale: 'all'`) → a map.
|
||
- **buildLocalizedPath** accepts `homeSlug: string | Record<string, string>`.
|
||
- **hreflang** gets the map → correct return tags (the end of the GSC error "Missing
|
||
return tags").
|
||
|
||
Works automatically through createPageMetadata. Condition: the home page must have
|
||
its slug filled in EVERY language (panel, per locale).
|
||
|
||
## Multilingual sitemap — a <url> per language (fixed in 1.2)
|
||
|
||
The sitemap emits a separate `<url>` for EVERY language (not only the default). As
|
||
Google requires: each language version = a separate `<loc>` + alternates. GSC now counts
|
||
all versions (8×3 = 24, not 8). Works automatically in buildSitemapEntries.
|
||
|
||
## Home page aliases — 301 instead of 200 (to wire in the project)
|
||
|
||
PROBLEM: `/pl/strona-glowna` (the full home slug) returns 200, just like `/pl` (root).
|
||
Google sees a duplicate ("Duplicate without user-selected canonical").
|
||
|
||
FIX (project): in page.tsx, if the slug matches the home page slug
|
||
in that language, redirect 301 to the root:
|
||
|
||
```ts
|
||
// page.tsx — after resolveRoute
|
||
const homeSlugForLocale = /* the home slug in this language, from settings */
|
||
if (slug?.length === 1 && slug[0] === homeSlugForLocale) {
|
||
redirect(`/${locale}`) // 301 to the root, do not serve a duplicate
|
||
}
|
||
```
|
||
|
||
The plugin does not do this automatically (a redirect is a project decision — a Next redirect
|
||
in page.tsx). But it is worth wiring so GSC shows no duplicates. Alternatively:
|
||
a canonical on `/pl/strona-glowna` pointing to `/pl` (less clean than a 301).
|
||
|
||
## Article/BlogPosting JSON-LD (blog)
|
||
|
||
For blog posts — buildArticleJsonLd generates Article/BlogPosting rich
|
||
results (headline, date, author, image):
|
||
|
||
```ts
|
||
import { buildArticleJsonLd } from '@intecion/ipal-kit'
|
||
const jsonLd = buildArticleJsonLd({
|
||
headline: post.title, url: postUrl, description: post.excerpt,
|
||
image: post.coverImage, datePublished: post.publishedAt,
|
||
author: post.author, publisherName: settings.siteName,
|
||
publisherLogo: settings.logo, type: 'BlogPosting',
|
||
})
|
||
```
|
||
|
||
Data from the document/panel. Google requires a headline + dates for a rich result.
|
||
|
||
## Robots — rich results (max-snippet, image/video preview)
|
||
|
||
Indexed pages automatically get directives that allow Google rich
|
||
results (buildMetadata generates them):
|
||
- `max-snippet: -1` — a full-length snippet (no limit)
|
||
- `max-image-preview: large` — a large image preview in results
|
||
- `max-video-preview: -1` — a full video preview
|
||
|
||
noindex pages (policies) get `index: false, follow: true` — without the above.
|
||
Zero configuration — works automatically for every page through createPageMetadata.
|
||
|
||
## Open Graph — full fields (type, siteName, url, description)
|
||
|
||
buildMetadata generates complete OG for social sharing (Facebook, LinkedIn, Slack):
|
||
- `og:title` — page title
|
||
- `og:description` — meta.description → fallback siteDescription (inherits)
|
||
- `og:image` — defaultShareImage / page image
|
||
- `og:type` — 'website'
|
||
- `og:site_name` — siteName from the panel
|
||
- `og:url` — the page canonical
|
||
- `og:locale` — the page language
|
||
|
||
Everything from the panel, automatically. The OG description inherits from meta.description (or the
|
||
global siteDescription when empty) — see below.
|
||
|
||
## Fallback meta description (siteDescription)
|
||
|
||
A page without `meta.description` → the plugin uses the global `siteDescription` from
|
||
SiteSettings. Better than no description, but Google ignores the same description on many pages
|
||
— that is why auto-fill (above) gives each page a description from its own content,
|
||
and the fallback stays for pages without content in blocks.
|
||
|
||
- The **siteDescription** field in SiteSettings → General (localized, textarea)
|
||
- buildMetadata: `meta.description || siteDescription`
|
||
- The editor fills it once globally; pages without their own description inherit it
|
||
|
||
## llms.txt — a site description for AI agents (GEO)
|
||
|
||
`buildLlmsTxt` generates `/llms.txt` (the llmstxt.org standard) — a Markdown file
|
||
describing the site for AI agents / LLM crawlers. Like buildRobots/sitemap:
|
||
the plugin knows the name, description and pages, so it generates it automatically.
|
||
|
||
```ts
|
||
// app/llms.txt/route.ts
|
||
import { buildLlmsTxt } from '@intecion/ipal-kit'
|
||
import { getCachedPayload } from '@/lib/content'
|
||
import { i18nConfig } from '@/i18n.config'
|
||
|
||
export const dynamic = 'force-dynamic'
|
||
|
||
export async function GET() {
|
||
const body = await buildLlmsTxt({
|
||
payload: await getCachedPayload(),
|
||
config: i18nConfig,
|
||
baseUrl: process.env.NEXT_PUBLIC_SERVER_URL!,
|
||
})
|
||
return new Response(body, {
|
||
headers: { 'Content-Type': 'text/plain; charset=utf-8' },
|
||
})
|
||
}
|
||
```
|
||
|
||
Structure: H1 (company name), blockquote (siteDescription), a list of pages as
|
||
Markdown links with descriptions. Data from the panel (siteName, siteDescription, pages);
|
||
skips drafts and noindex. Improves visibility in AI search (GEO —
|
||
Generative Engine Optimization) and "Agentic Browsing" audits.
|
||
|
||
Requires a filled siteDescription and sensible page meta.description values
|
||
(otherwise llms.txt will be thin) — or the `aiSummary` field (below), richer than the
|
||
meta description.
|
||
|
||
Since 1.13:
|
||
- under the description goes the editor's note from **Site settings → Search engines → About the site for
|
||
AI assistants** (facts to quote, per language) — see the "Search engines" section below;
|
||
- the list is no longer cut at 1000 documents (read in batches; `collectSiteIndex({ limit })`
|
||
still trims it if you want);
|
||
- `llmsRoute` / `llmsFullRoute` from `createContentHelpers` show only the open pages when "Under construction"
|
||
is on (`createLlmsTxtRoute({ getIncludedPaths })` at low level);
|
||
- the response has `Cache-Control` like the sitemap (CDN for an hour); the fallback response — `no-store`.
|
||
|
||
### buildSummaryField — a summary for AI (richer than meta)
|
||
|
||
The `aiSummary` field (localized textarea) — a concise page description for agents,
|
||
richer than the SEO `meta.description`. With `autoFill` (default) an empty field is
|
||
filled on save from the page CONTENT (blocks → text, trimmed to ~300
|
||
characters); the editor can override it, auto-fill never erases a hand-written description.
|
||
|
||
```ts
|
||
// collections/Pages.ts
|
||
import { buildSummaryField } from '@intecion/ipal-kit'
|
||
fields: [ /* … */ buildSummaryField() ]
|
||
```
|
||
|
||
Then point to it as the description source for AI (preferred over meta.description):
|
||
|
||
```ts
|
||
createContentHelpers({ …, summaryField: 'aiSummary' }) // llmsRoute, llmsFullRoute, mcpGET/POST — once
|
||
buildLlmsTxt({ …, summaryField: 'aiSummary' })
|
||
createLlmsTxtRoute({ …, summaryField: 'aiSummary' })
|
||
createSearchRoute({ …, summaryField: 'aiSummary' })
|
||
createMcpRoute({ …, summaryField: 'aiSummary' })
|
||
```
|
||
|
||
`buildSummaryField` options: `name` (`'aiSummary'`), `label`, `description`,
|
||
`maxLength` (300), `layoutField` (`'layout'`), `autoFill` (true), `overrides`.
|
||
The content comes from the page ITSELF — zero hard-coded client data.
|
||
|
||
### llms-full.txt — the full content in one file
|
||
|
||
`llms.txt` is an index; `llms-full.txt` is the full page content inline (the
|
||
llmstxt.org convention) — an agent gets the whole site in one request. Add a second route with
|
||
`full: true`:
|
||
|
||
```ts
|
||
// app/llms-full.txt/route.ts — usually: export { llmsFullRoute as GET } from '@/lib/content'
|
||
import { createLlmsTxtRoute } from '@intecion/ipal-kit'
|
||
import { getCachedPayload } from '@/lib/content'
|
||
import { i18nConfig } from '@/i18n.config'
|
||
export const dynamic = 'force-dynamic'
|
||
export const GET = createLlmsTxtRoute({
|
||
getCachedPayload, config: i18nConfig,
|
||
baseUrl: process.env.NEXT_PUBLIC_SERVER_URL!, full: true,
|
||
})
|
||
```
|
||
|
||
In `full` mode every published page is rendered to Markdown by
|
||
`blocksToMarkdown` (fetch depth 1, so images are populated). See
|
||
[content.md](./content.md) (Markdown per page).
|
||
|
||
## robots.txt — let AI bots in (so chat can read the site)
|
||
|
||
The most common reason that "chat does not read the site" is a blocked or unlisted AI bot
|
||
UA. `buildRobots` by default (`aiBots: 'allow'`) explicitly lets in assistant/search
|
||
bots and training bots:
|
||
|
||
```ts
|
||
// app/robots.ts
|
||
import { buildRobots } from '@intecion/ipal-kit'
|
||
export default function robots() {
|
||
return buildRobots({ baseUrl: process.env.NEXT_PUBLIC_SERVER_URL! })
|
||
}
|
||
```
|
||
|
||
`aiBots` modes:
|
||
- `'allow'` (default) — explicit allow for assistants and training bots (ClaudeBot,
|
||
GPTBot, PerplexityBot, Google-Extended…). Protects against losing AI visibility
|
||
if the `*` rule ever gets tighter.
|
||
- `'block-training'` — lets in assistants/search (AI answers, visibility),
|
||
blocks training crawlers. For clients who want to be in AI, but not in
|
||
model training.
|
||
- `'disallow'` — blocks all known AI bots.
|
||
- `false` — no AI rules (only `*`).
|
||
|
||
Bot lists: `AI_ASSISTANT_BOTS`, `AI_TRAINING_BOTS` (exported; override them
|
||
with `aiAssistantAgents` / `aiTrainingAgents`). `Next` accepts `rules` as an
|
||
array — with AI bots active, an array of rules is returned. 1.13 added the
|
||
assistants `Claude-User`, `MistralAI-User`, `DuckAssistBot`.
|
||
|
||
Per-bot exceptions — `aiBotRules` wins over `aiBots`: a listed bot leaves its group
|
||
and gets its own rule (you can add a bot outside the lists):
|
||
|
||
```ts
|
||
buildRobots({
|
||
baseUrl,
|
||
aiBots: 'block-training',
|
||
aiBotRules: [
|
||
{ userAgent: 'GPTBot', access: 'allow' }, // allow OpenAI training after all
|
||
{ userAgent: 'Bytespider', access: 'disallow' },
|
||
],
|
||
})
|
||
```
|
||
|
||
### AI bots from the panel — getRobots (1.13)
|
||
|
||
The editor sets the policy and exceptions in **Site settings → Search engines → AI assistants**.
|
||
For robots.txt to read them, replace `robots` with `getRobots` (async, reads Site settings
|
||
per request):
|
||
|
||
```ts
|
||
// app/robots.ts
|
||
export { getRobots as default } from '@/lib/content'
|
||
export const dynamic = 'force-dynamic'
|
||
```
|
||
|
||
- The "As set by the developer" policy (default) = what is in `createContentHelpers({ robots })`.
|
||
- Exceptions from the panel are added to `robots.aiBotRules` from code (the panel comes last, so it wins).
|
||
- A user agent from the panel: one token (`[\w\-.*/]`), no spaces or newlines — an entry
|
||
"Bot\nDisallow: /" is rejected and cannot inject a rule.
|
||
- Database unavailable → the options from code. `IPAL_NOINDEX=1` still wins over everything.
|
||
- `robots` (sync) stays unchanged — it ignores the panel.
|
||
|
||
## Sitemap — readable in the browser, zero files in the project
|
||
|
||
`createContentHelpers` returns `sitemapRoute`: XML for crawlers, and for people a
|
||
ready look (tiles, hreflang pills, light/dark mode) **served by the
|
||
plugin from the same route** (`/sitemap.xml?style`). The project has no `sitemap.css`,
|
||
copies nothing from `node_modules`, passes no `cssUrl`. The whole route file:
|
||
|
||
```ts
|
||
// src/app/sitemap.xml/route.ts
|
||
export { sitemapRoute as GET } from '@/lib/content'
|
||
export const dynamic = 'force-dynamic'
|
||
```
|
||
|
||
- **Heading** = "XML Sitemap" (no company/site name).
|
||
- **Line under the heading** = the technology provider: "Technology by Intecion.com".
|
||
- It is CSS on XML (`<?xml-stylesheet type="text/css"?>`, a W3C standard) — **not XSLT**,
|
||
which browsers are dropping. Google ignores the directive; zero SEO impact.
|
||
|
||
Changing the look — once, in `lib/content.ts`, not in files:
|
||
```ts
|
||
createContentHelpers({
|
||
config, content, i18n: i18nConfig,
|
||
sitemapStyle: { accent: '#0f766e' }, // accent colour
|
||
// sitemapStyle: { credit: false }, // no provider line
|
||
// sitemapStyle: false, // raw XML (the browser's native view)
|
||
})
|
||
```
|
||
|
||
Lower level (without `createContentHelpers`): `createSitemapRouteHandler(sitemap, { style })`,
|
||
`buildSitemapXml(entries, { cssUrl })`, `buildSitemapCss(options)`. The `cssUrl` option
|
||
(your own stylesheet in `public/`) still works, but is not needed.
|
||
|
||
### IMPORTANT — one sitemap, not two
|
||
|
||
If you use `app/sitemap.xml/route.ts`, DELETE `app/sitemap.ts` (MetadataRoute).
|
||
Two sitemaps under different paths confuse crawlers. Pick one:
|
||
- **`sitemap.xml/route.ts` + `sitemapRoute`** (recommended) — readable in the browser, look from the plugin
|
||
- **`sitemap.ts`** (`export { sitemap as default }`) — the browser's native XML view
|
||
|
||
Both are equally good for Google — it is about readability for humans, not SEO.
|
||
|
||
## Search engines — Search Console verification, AI bots, llms.txt note (1.13)
|
||
|
||
The **Site settings → Search engines** tab (on by default; empty fields change
|
||
nothing; `ipalKit({ searchSettings: false })` removes it — also without `seo` (`seo: { searchSettings }` still works; the top-level option wins); the function
|
||
`searchSettings: (fields) => fields` gets the plugin's fields and returns your own — add, remove,
|
||
relabel; the helpers read the names `searchVerification` / `aiCrawlers` / `llmsIntro`):
|
||
|
||
| Field | Where it goes |
|
||
|---|---|
|
||
| `searchVerification.google` | `<meta name="google-site-verification">` on every page |
|
||
| `searchVerification.bing` | `<meta name="msvalidate.01">` (Bing Webmaster — Bing's index feeds ChatGPT Search and Copilot) |
|
||
| `searchVerification.yandex` | `<meta name="yandex-verification">` |
|
||
| `aiCrawlers.policy`, `aiCrawlers.rules` | robots.txt through `getRobots` (above) |
|
||
| `llmsIntro` (per language) | `/llms.txt` under the site description |
|
||
|
||
**Verify Search Console by DNS (recommended)** — a TXT record on the domain (property type
|
||
**Domain**), see [deployment.md](./deployment.md) §6. It needs nothing from the plugin:
|
||
leave the verification fields **empty** (that is the normal state) and nothing warns. For Bing,
|
||
import the site from Search Console — no code needed either.
|
||
|
||
The meta-tag fields are **optional** — only for URL-prefix verification (HTML tag), when DNS
|
||
is not possible. Then the editor pastes just the code **or the whole tag** `<meta … content="…">`
|
||
from Search Console — only the code is saved; anything that is not a simple token is rejected
|
||
(the value lands in the `<head>` of every page). `generatePageMetadata` / `createPageMetadata`
|
||
add `verification` by themselves — zero code in the project. Your own generator:
|
||
`verificationFrom(settings)` → `Metadata.verification`; robots: `robotsOptionsFrom(settings)`.
|
||
After pasting the code: Search Console → Verify. The page must be rendered dynamically
|
||
or after revalidation (ISR), so the new tag is in the HTML.
|
||
|
||
Migration: new columns in `site_settings` — a Postgres project generates a migration
|
||
(`payload migrate:create`) as with any update that adds fields.
|
||
|
||
### Search Console API (data in the panel) — not built in
|
||
|
||
Clicks/queries from Search Console in the admin would need a Google service account (JSON with
|
||
a private key) added as a user in the GSC property, and the `googleapis` library
|
||
or JWT signing. The plugin does not do this (decision: DNS domain verification, data stays in Search Console itself).
|
||
|
||
## GEO — what the plugin means by "visibility in AI" (assumptions)
|
||
|
||
GEO (generative engine optimization) = the site is **found, read and
|
||
quoted** by AI assistants (ChatGPT, Claude, Perplexity, Gemini, Copilot). The plugin
|
||
assumes four things really work — there are no hidden "AI rankings":
|
||
|
||
1. **Access** — an AI bot can fetch the page: robots.txt with explicit rules (`aiBots`,
|
||
panel), no block in the CDN/WAF (the plugin cannot see that — check Cloudflare
|
||
"Block AI bots"). An assistant (fetches on the user's request) ≠ a training crawler.
|
||
2. **The index the assistant searches** — Bing (ChatGPT Search, Copilot) → IndexNow +
|
||
Bing verification; Google (AI Overviews, Gemini) → sitemap + Search Console.
|
||
3. **Readable content** — server-rendered HTML, Markdown (`/md/…`, `Link
|
||
rel=alternate`), `llms.txt` / `llms-full.txt` as an index and the full content. `llms.txt` is a
|
||
convention (llmstxt.org), not a standard — it does no harm and promises no traffic.
|
||
4. **Signals for quoting** — unambiguous facts: Organization/LocalBusiness with `sameAs`,
|
||
`dateModified`/`datePublished` (Article, WebPage), breadcrumbs, FAQ, `speakable`,
|
||
`aiSummary`, the `llmsIntro` note (who, what, where, since when — sentences that can be
|
||
quoted without context).
|
||
|
||
The plugin does NOT: generate content "for AI", hide content from people, serve AI bots a different
|
||
version than people (cloaking), or measure citations (no public API).
|
||
|
||
## JsonLdGraph — the @graph wrapper (no company model)
|
||
|
||
The plugin provides Schema.org building blocks (buildWebSiteJsonLd, buildOrganizationJsonLd,
|
||
buildLocalBusinessJsonLd, buildSiteNavigationJsonLd...) and `JsonLdGraph` —
|
||
a component that wraps nodes in `@graph` + a safe `<script>`. But it does NOT impose
|
||
a company data model.
|
||
|
||
```tsx
|
||
import { buildWebSiteJsonLd, buildOrganizationJsonLd } from '@intecion/ipal-kit'
|
||
import { JsonLdGraph } from '@intecion/ipal-kit/rsc' // component → the /rsc entry
|
||
|
||
// The project builds nodes from ITS OWN data and picks the @type for ITS market
|
||
const website = buildWebSiteJsonLd({ name, url })
|
||
const org = buildOrganizationJsonLd({ name, url, logo })
|
||
const business = { '@type': 'HVACBusiness', taxID: company.abn, areaServed: company.serviceArea }
|
||
|
||
<JsonLdGraph schemas={[website, org, business]} />
|
||
```
|
||
|
||
### Boundary: company data → the PROJECT, not the plugin
|
||
|
||
The `Company`/`Header`/`Footer` globals are defined by the PROJECT, not the plugin. Because the company
|
||
data model differs per country and industry:
|
||
|
||
| Country | Registration fields |
|
||
|---|---|
|
||
| PL | NIP, KRS, REGON (+ barAssociation for law firms, PWZ for doctors) |
|
||
| AU | ABN, entityName, licenceText, serviceArea |
|
||
| US | EIN, State |
|
||
| UK | Companies House, VAT ID |
|
||
|
||
A rigid `buildCompanyGlobal()` in the plugin would be a **leaky abstraction** — an Australian
|
||
project would have a dead NIP field and a missing ABN. So:
|
||
|
||
- **Plugin:** Schema building blocks (Organization, LocalBusiness, WebSite, SiteNavigation)
|
||
+ JsonLdGraph (wrapper + safe render)
|
||
- **Project:** its own `src/globals/Company.ts` for its country/industry + mapping its
|
||
data to the right `@type` (LegalService in PL, HVACBusiness in AU)
|
||
|
||
This removes the ONLY real duplication (the @graph wrapper + script, ~20 lines),
|
||
leaving the data model to the project (where it belongs).
|
||
|
||
## speakable JSON-LD — fragments for AI/voice to read
|
||
|
||
`buildSpeakableJsonLd` marks which parts of the page are best suited to be
|
||
read aloud / quoted by AI assistants (a GEO signal). Add the node
|
||
to `@graph`:
|
||
|
||
```tsx
|
||
import { buildSpeakableJsonLd } from '@intecion/ipal-kit'
|
||
import { JsonLdGraph } from '@intecion/ipal-kit/rsc'
|
||
|
||
const speakable = buildSpeakableJsonLd({
|
||
url: canonical,
|
||
cssSelectors: ['h1', '.lead'], // default ['h1', '.speakable']
|
||
})
|
||
<JsonLdGraph schemas={[...otherNodes, speakable]} />
|
||
```
|
||
|
||
In the project markup mark the matching elements (e.g. `className="speakable"` or
|
||
a `.lead` section with a summary). Selectors that match nothing are ignored —
|
||
do not point at navigation or boilerplate, only standalone, readable text.
|
||
It complements Markdown/llms: the assistant extracts the page's key content more easily.
|
||
|
||
## 1.9.1 — page structured data, IndexNow, sameAs, opening hours
|
||
|
||
- **`getPageJsonLd(locale, slug, { faq, pageType, entryType, breadcrumbs })`** from `createContentHelpers`
|
||
(the page node is built by `buildWebPageJsonLd` — also available on its own for custom routes):
|
||
WebPage / CollectionPage / BlogPosting (language, `dateModified`, image), BreadcrumbList from the real
|
||
route (page titles from the panel), FAQPage when the project maps its FAQ block. In `[[...slug]]/page.tsx`:
|
||
`<JsonLdGraph schemas={await getPageJsonLd(locale, slug)} />`.
|
||
- **Entries that are not articles** (1.11.0): `pageJsonLd.entries` — the main node per collection instead of
|
||
`BlogPosting`; breadcrumbs and FAQ still come from the plugin. Context: `{ doc, url, image, description, siteName, archive, locale }`.
|
||
```ts
|
||
createContentHelpers({ pageJsonLd: { entries: {
|
||
products: ({ doc, url, image, siteName }) => buildProductJsonLd({ name: String(doc.title), sku: String(doc.sku), url, image, brand: siteName,
|
||
price: doc.price?.amount ? { amount: doc.price.amount, currency: doc.price.currency, kind: 'from' } : null }),
|
||
categories: ({ doc, url, description }) => buildWebPageJsonLd({ type: 'CollectionPage', name: String(doc.title), url, description }),
|
||
} } })
|
||
```
|
||
**`buildProductJsonLd({ name, url, sku, description, image, category, brand, price, availability })`** — Product;
|
||
`Offer` only with a real price from the panel (`kind: 'exact'` → `price`, `'from'` → `minPrice`); a product "on request"
|
||
(no price) gets no `Offer` — an estimated price in structured data is misleading.
|
||
- **`buildNavigationJsonLd({ items: header.navItems, baseUrl, locale, config, homeSlug })`** — navigation from
|
||
the header global (page links per language, own domain only, no duplicates). A different global shape:
|
||
`getLink` / `getChildren`.
|
||
- **`buildLocalBusinessJsonLd({ type: 'Dentist', openingHours: company.hours, … })`** — `type` is any
|
||
schema.org type; hours as the editor's text (PL/EN/DE: "Pn-Pt: 8-17, Sob: 9-13, Nd nieczynne") →
|
||
`formatOpeningHours` → `['Mo-Fr 08:00-17:00', 'Sa 09:00-13:00']`. Unreadable text is skipped.
|
||
- **Site settings → sameAs** (company profiles) → `sameAsUrls(settings)` for Organization/LocalBusiness.
|
||
- **Site settings → Default share image** works as the OG image of pages without their own (it used to be ignored).
|
||
Metadata has an X/Twitter card, image dimensions and alt, and entries get `og:type=article` with dates.
|
||
- **Sitemap with images** (`<image:image>`): by default the page's SEO image; your own source:
|
||
`createContentHelpers({ sitemapImages: (doc) => [...] })`.
|
||
- **IndexNow:** `ipalKit({ indexNow: true })` + the route `src/app/indexnow-key.txt/route.ts`
|
||
(`createIndexNowKeyRoute`). After a page/entry is published, its addresses in all languages go to Bing &
|
||
co. (ChatGPT Search and Copilot use Bing's index). Production with public https only.
|
||
Key: Site integrations → IndexNow (generated on save) or `INDEXNOW_KEY`. Google does not
|
||
support IndexNow — for Google, use the sitemap.
|
||
Key route from `lib/content`: `export { indexNowKeyRoute as GET } from '@/lib/content'`.
|
||
By hand (e.g. content imported by a script): `submitToIndexNow({ payload, urls })` (key: `getIndexNowKey(payload)`)
|
||
— never throws, only logs. With `IPAL_NOINDEX=1` (staging) it sends nothing, even with
|
||
`NODE_ENV=production` (1.13).
|
||
- **llms.txt / llms-full.txt** cover content collection entries (`content`) and all languages; MCP
|
||
`list_pages` too. Shared source: `collectSiteIndex`.
|
||
|
||
## noindex — staging, Markdown, protection (1.9.1)
|
||
|
||
- **`IPAL_NOINDEX=1`** in the staging/preview env: robots `Disallow: /`, `noindex, nofollow` in meta,
|
||
`X-Robots-Tag` in `buildSecurityHeaders`. Never on production (`ipal-seo-check` reports it).
|
||
- Markdown versions (`/md/…`) and the llms files have `X-Robots-Tag: noindex`; Markdown also has
|
||
`Link: <html-url>; rel="canonical"` — AI reads it, Google sees no duplicates.
|
||
- `buildNoindexField` does not allow ticking noindex on the home page and archive pages.
|
||
- When to use noindex: the table in AGENT.md §0c. Legal policies stay indexed by default.
|
||
|
||
## Turn off, override, extend
|
||
|
||
- **Turn off the module:** leave out `seo` in `ipalKit()` — no SEO tab and no auto-fill. The Site settings →
|
||
Search engines tab stays (remove it with the top-level `searchSettings: false`). The front helpers (`buildMetadata`, `buildRobots`, the JSON-LD builders) are plain functions and work without it.
|
||
- **Auto-fill:** `autoFill: false` turns it off; `autoFill: { title, description, content, descriptionLength }`
|
||
remaps the source fields. Skip it for one save with `context: { [SKIP_AUTO_FILL]: true }`.
|
||
- **Description hint:** `descriptionCheck: false` removes it; `descriptionCheck: { settingsSlug, siteDescriptionField }`
|
||
points it at another global/field.
|
||
- **Titles and descriptions:** `generateTitle` / `generateDescription` replace plugin-seo's generators;
|
||
`fields` adds your own fields to the SEO group. Per page, **Exact page title** beats the composed title.
|
||
- **Search engines tab:** `ipalKit({ searchSettings: false })` removes it (with or without `seo`); `searchSettings: (fields) => fields` adds, removes or
|
||
relabels fields (keep `searchVerification` / `aiCrawlers` / `llmsIntro`, or read your own fields in your routes).
|
||
- **The Site settings global itself** (where the SEO fields live): `ipalKit({ globalOverrides: { 'site-settings': … } })`
|
||
— an object is merged over the plugin's global (`access`, `admin` and `hooks` key by key: your access rules win,
|
||
your hooks run after the plugin's; other keys such as `fields` replace the plugin's); a function
|
||
`(global) => global` gives full control (drop a plugin hook, append fields). The same works for
|
||
`'site-integrations'` (IndexNow key).
|
||
- **Sitemap / robots / llms:** the project has the last word through `createContentHelpers` options —
|
||
`sitemapEntries`, `sitemapImages`, `sitemapOptions`, `sitemapStyle`, `underConstructionSeo: false`,
|
||
`robots: { disallowParams, extraDisallow, adminRoute, disallow, aiBots, aiBotRules, … }`, `summaryField`,
|
||
`pageJsonLd.entries`. Or skip the factory handlers and build your own routes from the low-level builders
|
||
(`buildSitemapEntries`, `buildRobots`, `buildLlmsTxt`, `createSitemapRouteHandler`).
|
||
- **IndexNow:** off unless `ipalKit({ indexNow: true })`.
|