# Template SEO Meta Workflow

**Last Updated:** 2026-02-18  
**Purpose:** Research-driven meta tags (title, description, keywords) for template pages, aligned with blog seo-meta.json and META_TAGS_OPTIMIZATION_GUIDE.

## Overview

Template meta is generated from research data (keywords-sistrix, competitor-analysis, template-candidate-keywords) and stored in `template-data/{id}/data/seo-meta.json`. `load_template_config()` prefers this file over registry/template-keywords when present.

## Data Flow

```mermaid
flowchart LR
    A[keywords-sistrix.json] --> B[generate-template-seo-meta.php]
    C[competitor-analysis.json] --> B
    D[template-candidate-keywords.json] --> B
    B --> E[seo-meta.json]
    E --> F[load_template_config]
    F --> G[template-meta-generator]
```

## Source Priority

1. **keywords-sistrix.json** – Primary keyword, volume-ranked keywords (SISTRIX)
2. **competitor-analysis.json** – Competitor titles/descriptions (informational)
3. **template-candidate-keywords.json** – Fallback when no SISTRIX data
4. **template-registry.json** – Fallback when no template-data

## Workflow Steps

### 1. Run SISTRIX Keyword Collection

Ensure `template-data/{id}/data/keywords-sistrix.json` exists:

```bash
php v2/scripts/templates/collect-template-sistrix-keywords.php --template=id
```

### 2. Generate SEO Meta

```bash
php v2/scripts/templates/generate-template-seo-meta.php --template=id [--force]
```

Options:
- `--template=id` – Single template
- `--all` – All templates with template-data
- `--dry-run` – Show output without writing
- `--force` – Overwrite existing seo-meta.json

Output: `template-data/{id}/data/seo-meta.json`

### 3. Review and Edit (Optional)

Edit `seo-meta.json` manually for fine-tuning:
- **title:** 50–60 chars before " - Ordio" (generator adds suffix)
- **description:** 155–160 chars, benefit-driven, CTA
- **keywords:** Top 10 from research

### 4. Config Integration

`load_template_config()` automatically uses `seo-meta.json` when present. No further steps needed.

## Title Format

Per [META_TAGS_OPTIMIZATION_GUIDE.md](../../content/META_TAGS_OPTIMIZATION_GUIDE.md):

- **Optimal:** 50–60 characters (Google truncates ~60)
- `{Primary Keyword} – Kostenloser Download | Vorlagen` or shorter `{Primary Keyword} | Vorlagen`
- If primary keyword > 55 chars: `{Primary Keyword} | Vorlagen`
- `template-meta-generator.php` adds ` - Ordio` if not present
- **Research-driven titles** (seo-meta.json with `| Vorlagen`): generator adds only ` - Ordio`; skips redundant `: Kostenlos & rechtssicher`
- **Length enforcement:** Titles over 60 chars are truncated at word boundary (suffix ` - Ordio` preserved)

## Description Format

- Benefit-driven, primary keyword, CTA
- 155–160 chars
- Template-specific benefits (ArbZG, DATEV, Minijob, etc.)

## Slug Selection (New Templates)

Template slug = template ID (URL path `/vorlagen/{id}`). **Data-driven:** derive from primary keyword (keywords-sistrix.json). Per Google Search Central: use audience language (German).

**Rules:**
1. **German only** – no English words (shift, planning, time, tracking, payroll, etc.)
2. **Primary keyword** – hyphenated, lowercase (e.g. `lohnabrechnung-vorlage`)
3. **Differentiation** – when overlap with existing template: add suffix (-premium, -excel, -checkliste)
4. **50-60 chars** – keep URLs short
5. **Umlauts** – use ae, oe, ue (e.g. gefaehrdungsbeurteilung)

**Pre-publication:**
- Run `php v2/scripts/templates/validate-template-slug-keyword-alignment.php --all`
- Run `php v2/scripts/templates/analyze-template-slug-keyword-matrix.php` for recommended slugs
- Add 301 redirects in `.htaccess` if changing existing slugs

See [TEMPLATE_SLUG_MIGRATION_GUIDE.md](TEMPLATE_SLUG_MIGRATION_GUIDE.md).

## Related Documentation

- [META_TAGS_OPTIMIZATION_GUIDE.md](../../content/META_TAGS_OPTIMIZATION_GUIDE.md)
- [SEO_GEO_AEO_CHECKLIST.md](../../content/blog/SEO_GEO_AEO_CHECKLIST.md)
- [TEMPLATE_CONTENT_CREATION_WORKFLOW.md](TEMPLATE_CONTENT_CREATION_WORKFLOW.md)
- [TEMPLATE_DATA_COLLECTION_GUIDE.md](TEMPLATE_DATA_COLLECTION_GUIDE.md)
