Skip to content

Commit 78fc95b

Browse files
committed
SEO/GEO: prerendered pages with real URLs, structured data, llms.txt
- Path-based URLs (/en/contract/) instead of hash routing; old #/ links redirect - Every page prerendered as static HTML (react-dom/static) and hydrated in the browser - Per-page title, description, canonical, hreflang, Open Graph - JSON-LD: Course, HowTo with steps, VideoObject, BreadcrumbList - sitemap.xml with language alternates, robots.txt welcoming AI crawlers - llms.txt, llms-full.txt, and a Markdown version of every page - Scenario diagram drawn like the Entropy Data map (ports on the card edges) - Airflow bonus in the CI/CD chapter; author line removed from the footer
1 parent 7a8429b commit 78fc95b

40 files changed

Lines changed: 617 additions & 250 deletions

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ orders_v2.odcs.*
1818
orders.odps.*
1919
sku_sales_per_year.*
2020
orders_v2.consumer_sku_sales.odcs.*
21+
tutorial/dist-ssr

‎exercises/part-d/exercise9-ci-cd-with-github-actions.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,3 +198,4 @@ A breaking change in a contract breaks consumers. The pipeline catches it *befor
198198

199199
Running Entropy Data locally (Community Edition)? GitHub can't reach your laptop, so this only works with the cloud.
200200
- Linked your contracts to semantic concepts (Exercise 8)? The CLI resolves these links on the Entropy Data host during `ci`. Add `--no-inline-references` to the test step if the pipeline can't reach it.
201+
- **Schedule production tests with Airflow:** CI tests a contract when it changes, but the data changes every day. The [Data Contract provider for Airflow](https://github.com/datacontract/airflow-provider-datacontract) adds a `DataContractTestOperator` that runs `datacontract test` as a quality gate in your DAGs. See the [scheduling docs for Airflow](https://docs.datacontract.com/scheduling/airflow).

‎tutorial/index.html‎

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,16 @@
33
<head>
44
<meta charset="UTF-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6-
<title>Data Contracts in Practice</title>
7-
<meta name="description" content="A free, hands-on tutorial: data contracts with ODCS 3.2, data products with ODPS, open-source tools, AI context, and CI/CD. In English and German." />
8-
<link rel="canonical" href="https://learn.datacontract.com/" />
6+
<!--head-->
97
<meta property="og:type" content="website" />
108
<meta property="og:site_name" content="learn.datacontract.com" />
11-
<meta property="og:url" content="https://learn.datacontract.com/" />
12-
<meta property="og:title" content="Data Contracts in Practice" />
13-
<meta property="og:description" content="A free, hands-on tutorial: from your first data contract to CI/CD. ODCS 3.2, ODPS, AI context, GitHub Actions." />
149
<meta property="og:image" content="https://learn.datacontract.com/og-image.png" />
1510
<meta property="og:image:width" content="1200" />
1611
<meta property="og:image:height" content="630" />
17-
<meta property="og:image:alt" content="Data Contracts in Practice: a free, hands-on tutorial at learn.datacontract.com" />
1812
<meta name="twitter:card" content="summary_large_image" />
19-
<meta name="twitter:title" content="Data Contracts in Practice" />
20-
<meta name="twitter:description" content="A free, hands-on tutorial: from your first data contract to CI/CD." />
2113
<meta name="twitter:image" content="https://learn.datacontract.com/og-image.png" />
22-
<link rel="icon" type="image/png" href="./favicon.png" />
23-
<link rel="apple-touch-icon" href="./favicon.png" />
14+
<link rel="icon" type="image/png" href="/favicon.png" />
15+
<link rel="apple-touch-icon" href="/favicon.png" />
2416
<link rel="preconnect" href="https://fonts.googleapis.com" />
2517
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
2618
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet" />

‎tutorial/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"type": "module",
66
"scripts": {
77
"dev": "vite",
8-
"build": "tsc -b && vite build",
8+
"build": "tsc -b && vite build && vite build --ssr src/entry-server.tsx --outDir dist-ssr && node scripts/prerender.mjs",
99
"preview": "vite preview"
1010
},
1111
"dependencies": {

‎tutorial/public/videos/videos.json‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"ci-cd": {
3+
"duration": 128.0
4+
},
5+
"consumer-driven": {
6+
"duration": 141.6
7+
},
8+
"contract-first": {
9+
"duration": 147.6
10+
},
11+
"contract": {
12+
"duration": 166.1
13+
},
14+
"data-product": {
15+
"duration": 85.2
16+
},
17+
"evolution": {
18+
"duration": 145.1
19+
},
20+
"implement": {
21+
"duration": 113.7
22+
},
23+
"publish": {
24+
"duration": 146.3
25+
},
26+
"semantics": {
27+
"duration": 130.2
28+
},
29+
"setup": {
30+
"duration": 62.3
31+
}
32+
}

‎tutorial/scripts/mdx-to-md.mjs‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// Converts a tutorial chapter (MDX with our components) into plain Markdown for
2+
// llms.txt / llms-full.txt and the per-page .md files that AI systems can read.
3+
import { readFileSync } from 'node:fs'
4+
import { dirname, resolve } from 'node:path'
5+
6+
const SITE = 'https://learn.datacontract.com'
7+
8+
const indent = (text, prefix) => text.split('\n').map((l) => (l ? prefix + l : prefix.trimEnd())).join('\n')
9+
10+
// JSX attribute values like {["a", "b"]} or {"text"} are JSON in our content
11+
function attr(source, name) {
12+
const m = source.match(new RegExp(`${name}=(?:"([^"]*)"|\\{([\\s\\S]*?)\\}(?=\\s+\\w+=|\\s*>))`))
13+
if (!m) return undefined
14+
if (m[1] !== undefined) return m[1]
15+
try { return JSON.parse(m[2]) } catch { return m[2] }
16+
}
17+
18+
export function mdxToMarkdown(source, file) {
19+
let md = source
20+
21+
// reference solutions included from files
22+
md = md.replace(/```(\w+) file=(\S+)\n```/g, (_, lang, path) => {
23+
const content = readFileSync(resolve(dirname(file), path), 'utf8').trimEnd()
24+
return `\`\`\`${lang} title=${path.split('/').pop()}\n${content}\n\`\`\``
25+
})
26+
27+
// macOS/Linux and Windows variants of a command
28+
md = md.replace(/```bash\n([\s\S]*?)```\s*```powershell\n([\s\S]*?)```(?:\s*```output\n([\s\S]*?)```)?/g, (_, unix, win, out) =>
29+
`macOS / Linux:\n\n\`\`\`bash\n${unix}\`\`\`\n\nWindows (PowerShell):\n\n\`\`\`powershell\n${win}\`\`\`` + (out ? `\n\nOutput:\n\n\`\`\`text\n${out}\`\`\`` : ''))
30+
31+
md = md.replace(/<Quiz([\s\S]*?)>([\s\S]*?)<\/Quiz>/g, (_, attrs, explanation) => {
32+
const question = attr(attrs, 'question')
33+
const options = attr(attrs, 'options') ?? []
34+
const answer = Number(attr(attrs, 'answer'))
35+
return `**Quick check:** ${question}\n\n${options.map((o, i) => `- ${o}${i === answer ? ' (correct)' : ''}`).join('\n')}\n\n${explanation.trim()}`
36+
})
37+
38+
md = md.replace(/<Callout([^>]*)>([\s\S]*?)<\/Callout>/g, (_, attrs, body) => {
39+
const title = attr(attrs, 'title') ?? (attr(attrs, 'type') ?? 'note').replace(/^\w/, (c) => c.toUpperCase())
40+
return indent(`**${title}**\n\n${body.trim()}`, '> ')
41+
})
42+
md = md.replace(/<Step id="([^"]+)" title="([^"]+)">/g, '### $2')
43+
md = md.replace(/<Solution(?: title="([^"]*)")?>/g, (_, t) => `**Solution${t ? `: ${t}` : ''}**`)
44+
md = md.replace(/<Goals>/g, '**You will learn:**')
45+
md = md.replace(/<Os name="unix">/g, '**macOS / Linux:**').replace(/<Os name="windows">/g, '**Windows:**')
46+
md = md.replace(/<ScenarioDiagram[^>]*\/>/g, '_Scenario: the Orders data product (output ports orders_v1 and orders_v2) is consumed by the SKU Sales data product, which the purchasing team uses._')
47+
md = md.replace(/<\/?(Step|Solution|Goals|OsTabs|Os)>/g, '')
48+
49+
// absolute URLs for links and images
50+
md = md.replace(/\]\((\/[^)]*)\)/g, `](${SITE}$1)`)
51+
md = md.replace(/\n{3,}/g, '\n\n')
52+
return md.trim() + '\n'
53+
}

‎tutorial/scripts/prerender.mjs‎

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
// Prerenders every page as static HTML with per-page meta tags and structured data,
2+
// and writes sitemap.xml, robots.txt, llms.txt, llms-full.txt and a Markdown version of
3+
// each page. Runs after `vite build` (client) and `vite build --ssr src/entry-server.tsx`.
4+
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs'
5+
import { dirname, join } from 'node:path'
6+
import { fileURLToPath, pathToFileURL } from 'node:url'
7+
import { mdxToMarkdown } from './mdx-to-md.mjs'
8+
9+
const root = join(dirname(fileURLToPath(import.meta.url)), '..')
10+
const dist = join(root, 'dist')
11+
const SITE = 'https://learn.datacontract.com'
12+
const LANGS = ['en', 'de']
13+
const PUBLISHED = '2026-10-04'
14+
15+
const { render, chapters, parts, exerciseNumber, href, t } = await import(pathToFileURL(join(root, 'dist-ssr/entry-server.js')).href)
16+
const template = readFileSync(join(dist, 'index.html'), 'utf8')
17+
const videos = JSON.parse(readFileSync(join(root, 'public/videos/videos.json'), 'utf8'))
18+
19+
const esc = (s) => String(s).replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;')
20+
const url = (lang, slug) => SITE + href(lang, slug)
21+
const mdxPath = (lang, slug) => join(root, 'src/content', lang, `${slug}.mdx`)
22+
const stepsWithTitles = (lang, slug) =>
23+
[...readFileSync(mdxPath(lang, slug), 'utf8').matchAll(/<Step id="([^"]+)" title="([^"]+)">/g)].map((m) => ({ id: m[1], title: m[2] }))
24+
const isoDuration = (seconds) => `PT${Math.floor(seconds / 60)}M${Math.round(seconds % 60)}S`
25+
26+
const publisher = { '@type': 'Organization', name: 'Entropy Data', url: 'https://www.entropy-data.com', logo: `${SITE}/entropy-data-logo.svg` }
27+
28+
function pageTitle(lang, chapter) {
29+
const ui = t(lang)
30+
const number = exerciseNumber(chapter.slug)
31+
if (chapter.slug === 'welcome') return `${ui.title}: ${ui.subtitle}`
32+
return `${number ? `${ui.exercise} ${number}: ` : ''}${chapter.title[lang]} · ${ui.title}`
33+
}
34+
35+
function structuredData(lang, chapter) {
36+
const ui = t(lang)
37+
const part = parts.find((p) => p.id === chapter.part)
38+
const data = [{
39+
'@context': 'https://schema.org',
40+
'@type': 'BreadcrumbList',
41+
itemListElement: [
42+
{ '@type': 'ListItem', position: 1, name: ui.title, item: url(lang, 'welcome') },
43+
...(chapter.slug === 'welcome' ? [] : [{ '@type': 'ListItem', position: 2, name: chapter.title[lang], item: url(lang, chapter.slug) }]),
44+
],
45+
}]
46+
if (chapter.slug === 'welcome') {
47+
data.push({
48+
'@context': 'https://schema.org',
49+
'@type': 'Course',
50+
name: ui.title,
51+
description: ui.subtitle,
52+
url: url(lang, 'welcome'),
53+
inLanguage: lang,
54+
isAccessibleForFree: true,
55+
educationalLevel: 'Beginner',
56+
teaches: ['Data contracts', 'Open Data Contract Standard (ODCS)', 'Open Data Product Standard (ODPS)', 'Data Contract CLI', 'Contract-first data products', 'Consumer-driven contracts', 'CI/CD for data contracts', 'Semantics and ontologies'],
57+
keywords: 'data contract, ODCS, ODPS, data product, data mesh, Data Contract CLI, data quality, CI/CD, GitHub Actions',
58+
provider: publisher,
59+
publisher,
60+
hasCourseInstance: { '@type': 'CourseInstance', courseMode: 'online', courseWorkload: 'PT6H' },
61+
hasPart: chapters.filter((c) => c.exercise).map((c) => ({ '@type': 'LearningResource', name: c.title[lang], url: url(lang, c.slug) })),
62+
offers: { '@type': 'Offer', price: 0, priceCurrency: 'EUR', category: 'Free' },
63+
})
64+
} else {
65+
const steps = stepsWithTitles(lang, chapter.slug)
66+
if (steps.length) {
67+
data.push({
68+
'@context': 'https://schema.org',
69+
'@type': 'HowTo',
70+
name: chapter.title[lang],
71+
description: chapter.summary[lang],
72+
inLanguage: lang,
73+
totalTime: `PT${chapter.minutes}M`,
74+
isPartOf: { '@type': 'Course', name: ui.title, url: url(lang, 'welcome') },
75+
about: part?.title[lang],
76+
publisher,
77+
step: steps.map((s, i) => ({ '@type': 'HowToStep', position: i + 1, name: s.title, url: `${url(lang, chapter.slug)}#step-${s.id}` })),
78+
})
79+
}
80+
}
81+
if (chapter.video && videos[chapter.slug]) {
82+
data.push({
83+
'@context': 'https://schema.org',
84+
'@type': 'VideoObject',
85+
name: `${chapter.title[lang]} (walkthrough)`,
86+
description: chapter.summary[lang],
87+
thumbnailUrl: `${SITE}/videos/${chapter.slug}.webp`,
88+
contentUrl: `${SITE}/videos/${chapter.slug}.mp4`,
89+
uploadDate: PUBLISHED,
90+
duration: isoDuration(videos[chapter.slug].duration),
91+
inLanguage: 'en',
92+
publisher,
93+
})
94+
}
95+
return data
96+
}
97+
98+
function head(lang, chapter, canonical) {
99+
const title = pageTitle(lang, chapter)
100+
const description = chapter.slug === 'welcome'
101+
? (lang === 'de'
102+
? 'Kostenloses Hands-on-Tutorial: Datenkontrakte mit ODCS 3.2, Datenprodukte mit ODPS 1.1, Data Contract CLI, KI-Kontext und CI/CD mit GitHub Actions.'
103+
: 'A free, hands-on tutorial: data contracts with ODCS 3.2, data products with ODPS 1.1, the Data Contract CLI, AI context, and CI/CD with GitHub Actions.')
104+
: `${chapter.summary[lang]} ${t(lang).title}: ${t(lang).subtitle}.`
105+
return [
106+
`<title>${esc(title)}</title>`,
107+
`<meta name="description" content="${esc(description)}" />`,
108+
`<link rel="canonical" href="${canonical}" />`,
109+
...LANGS.map((l) => `<link rel="alternate" hreflang="${l}" href="${url(l, chapter.slug)}" />`),
110+
`<link rel="alternate" hreflang="x-default" href="${url('en', chapter.slug)}" />`,
111+
`<link rel="alternate" type="text/markdown" href="${SITE}/${lang}/${chapter.slug}.md" />`,
112+
`<meta property="og:url" content="${canonical}" />`,
113+
`<meta property="og:title" content="${esc(title)}" />`,
114+
`<meta property="og:description" content="${esc(description)}" />`,
115+
`<meta property="og:locale" content="${lang === 'de' ? 'de_DE' : 'en_US'}" />`,
116+
`<meta property="og:image:alt" content="Data Contracts in Practice: a free, hands-on tutorial at learn.datacontract.com" />`,
117+
`<meta name="twitter:title" content="${esc(title)}" />`,
118+
`<meta name="twitter:description" content="${esc(description)}" />`,
119+
...structuredData(lang, chapter).map((d) => `<script type="application/ld+json">${JSON.stringify(d).replace(/</g, '\\u003c')}</script>`),
120+
].join('\n ')
121+
}
122+
123+
async function page(lang, chapter, file, canonical = url(lang, chapter.slug)) {
124+
const body = await render({ lang, slug: chapter.slug })
125+
const html = template
126+
.replace('<html lang="en">', `<html lang="${lang}">`)
127+
.replace('<!--head-->', head(lang, chapter, canonical))
128+
.replace('<div id="root"></div>', `<div id="root">${body}</div>`)
129+
mkdirSync(dirname(file), { recursive: true })
130+
writeFileSync(file, html)
131+
}
132+
133+
const welcome = chapters.find((c) => c.slug === 'welcome')
134+
for (const lang of LANGS) {
135+
for (const chapter of chapters) {
136+
const dir = chapter.slug === 'welcome' ? join(dist, lang) : join(dist, lang, chapter.slug)
137+
await page(lang, chapter, join(dir, 'index.html'))
138+
writeFileSync(join(dist, lang, `${chapter.slug}.md`),
139+
`# ${chapter.title[lang]}\n\n${chapter.summary[lang]}\n\nSource: ${url(lang, chapter.slug)}\n\n` + mdxToMarkdown(readFileSync(mdxPath(lang, chapter.slug), 'utf8'), mdxPath(lang, chapter.slug)))
140+
}
141+
}
142+
// the root page: the English welcome page for crawlers (visitors are redirected to their language)
143+
await page('en', welcome, join(dist, 'index.html'), url('en', 'welcome'))
144+
await page('en', { ...welcome, title: { en: 'Page not found', de: 'Seite nicht gefunden' } }, join(dist, '404.html'), url('en', 'welcome'))
145+
146+
// sitemap with language alternates
147+
const urls = LANGS.flatMap((lang) => chapters.map((c) => ({ lang, slug: c.slug })))
148+
writeFileSync(join(dist, 'sitemap.xml'), `<?xml version="1.0" encoding="UTF-8"?>
149+
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">
150+
${urls.map(({ lang, slug }) => ` <url>
151+
<loc>${url(lang, slug)}</loc>
152+
<lastmod>${PUBLISHED}</lastmod>
153+
${LANGS.map((l) => ` <xhtml:link rel="alternate" hreflang="${l}" href="${url(l, slug)}" />`).join('\n')}
154+
<xhtml:link rel="alternate" hreflang="x-default" href="${url('en', slug)}" />
155+
</url>`).join('\n')}
156+
</urlset>
157+
`)
158+
159+
// search engines and AI crawlers are welcome
160+
writeFileSync(join(dist, 'robots.txt'), `User-agent: *
161+
Allow: /
162+
163+
# AI crawlers and assistants are explicitly welcome
164+
${['GPTBot', 'OAI-SearchBot', 'ChatGPT-User', 'ClaudeBot', 'Claude-User', 'Claude-SearchBot', 'PerplexityBot', 'Perplexity-User', 'Google-Extended', 'Applebot-Extended', 'CCBot', 'Meta-ExternalAgent'].map((b) => `User-agent: ${b}\nAllow: /`).join('\n\n')}
165+
166+
Sitemap: ${SITE}/sitemap.xml
167+
`)
168+
169+
// llms.txt: an index for AI systems, llms-full.txt: the whole English tutorial as Markdown
170+
const en = t('en')
171+
const llms = [`# ${en.title}`, '',
172+
`> A free, hands-on tutorial on data contracts: put a PostgreSQL dataset under contract with the Open Data Contract Standard (ODCS 3.2), describe data products with the Open Data Product Standard (ODPS 1.1), design contract-first, use consumer-driven contracts, automate everything with GitHub Actions, and publish to a data product platform. Uses the open-source Data Contract CLI and Data Product CLI. Available in English and German. Maintained by Entropy Data.`, '',
173+
...parts.flatMap((p) => [`## ${p.title.en}`, '', ...chapters.filter((c) => c.part === p.id).map((c) => `- [${c.title.en}](${SITE}/en/${c.slug}.md): ${c.summary.en}`), '']),
174+
'## German version', '', ...chapters.map((c) => `- [${c.title.de}](${SITE}/de/${c.slug}.md): ${c.summary.de}`), '',
175+
'## Optional', '', `- [Full tutorial in one file](${SITE}/llms-full.txt)`, `- [Repository with exercises and reference solutions](https://github.com/datacontract/learn.datacontract.com)`,
176+
'- [Open Data Contract Standard](https://bitol-io.github.io/open-data-contract-standard/)', '- [Open Data Product Standard](https://bitol-io.github.io/open-data-product-standard/)', '- [Data Contract CLI](https://cli.datacontract.com)', '']
177+
writeFileSync(join(dist, 'llms.txt'), llms.join('\n'))
178+
writeFileSync(join(dist, 'llms-full.txt'), [`# ${en.title}`, '', ...chapters.map((c) => readFileSync(join(dist, 'en', `${c.slug}.md`), 'utf8'))].join('\n\n---\n\n'))
179+
180+
console.log(`prerendered ${urls.length} pages, sitemap.xml, robots.txt, llms.txt, llms-full.txt`)

0 commit comments

Comments
 (0)