Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .claude/skills/tetrak-ocr-design/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,31 @@ or a preview deploy served from a subdirectory — would reopen the trap.
`site/tests/site.spec.ts` follows every internal link on every page and checks the
masthead stays under the baseURL path.

## Share cards and structured data

`baseof.html` publishes three things about a page besides its title, and all
three read the same sentence from `partials/description.html`: `description`
where the page has one, else the standfirst, else the site description.

- `partials/social.html` writes the Open Graph tags. Twitter gets only
`twitter:card`; it falls back to the `og:` tags for the rest.
- `partials/share-card.html` returns the one share image,
`assets/images/design/share-card.png`. It is drawn by
`node scripts/render-share-card.mjs` from the design tokens and the home
page's standfirst, and committed. Re-run the script after changing that
standfirst. It is a PNG at a fixed, unfingerprinted address on purpose.
- `partials/structured-data.html` writes JSON-LD on three kinds of page: the
home page (Organization and WebSite), an article (TechArticle, with the
author from `data/authors.toml`) and a product page (SoftwareSourceCode).

**A product page needs a `software` map in its front matter**: `name`,
`repository`, `licence` (an SPDX identifier such as `MIT` or `Apache-2.0`) and
`language`. A missing key fails the build. `params.profiles` in `hugo.toml`
lists the profiles published as the organisation's `sameAs`.

`layouts/robots.txt` replaces Hugo's one-line default so that it names the
sitemap.

## No mkdocs markup

The site was migrated from mkdocs-material. Its extensions are **not** available
Expand Down
Binary file added site/assets/images/design/share-card.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions site/config/_default/hugo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ capitalizeListTitles = false
# The organisation, which the masthead links to since October 2026: the site
# describes several tools, each in its own repository under it.
org = "https://github.com/scattercode"
# The profiles that are Tetrak's own and nothing else's, published as the
# organisation's `sameAs` in the home page's structured data
# (layouts/partials/structured-data.html). The GitHub organisation above is
# deliberately not among them: it holds other projects as well.
profiles = ["https://huggingface.co/tetrak", "https://pypi.org/org/tetrak/"]

# The security watch at /security/ is built from sillybos's advisory record
# (docs/advisories/record.json in that repository): one page per advisory
Expand Down
5 changes: 5 additions & 0 deletions site/content/armenian-ocr.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ title: "Armenian text recognition"
kicker: "Open source"
standfirst: "A recogniser we trained ourselves for printed Armenian, published as a small library that adds the language to EasyOCR, with the model, the word list and the training data in the open."
description: "tetrak-easyocr-armenian: an open-source Armenian OCR model for EasyOCR, trained on proofread Armenian texts, reading Eastern and Western Armenian in either orthography. Weights on Hugging Face, Apache 2.0."
software:
name: "tetrak-easyocr-armenian"
repository: "https://github.com/scattercode/tetrak-easyocr-armenian"
licence: "Apache-2.0"
language: "Python"
---

## What it is for
Expand Down
5 changes: 5 additions & 0 deletions site/content/ocr/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ title: "Tetrak OCR"
kicker: "Open source"
standfirst: "Turns scans of unruly archive material into searchable text, on your own machine, choosing the best engine for each file and setting aside what it cannot read."
description: "Tetrak OCR: a local-first tool that runs several OCR engines over scans of archival material, keeps the best transcript of each file, and sends what it cannot trust to a person."
software:
name: "tetrak"
repository: "https://github.com/scattercode/tetrak"
licence: "MIT"
language: "Python"
---

Historical archives do not arrive as tidy, uniform PDFs. A real collection is a
Expand Down
5 changes: 5 additions & 0 deletions site/content/sillybos.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ title: "sillybos"
kicker: "Open source"
standfirst: "A small library that decides, before any image library or PDF renderer opens a file, whether it is one of the formats you meant to read, within the limits you expect, and if not, why. Read the tag; don't unroll the scroll."
description: "sillybos: a dependency-free Python library and command that checks a JPEG, PNG, TIFF or PDF before any decoder opens it: format from the first bytes, header limits, rare codings refused, a plain reason for each refusal. MIT licensed."
software:
name: "sillybos"
repository: "https://github.com/scattercode/sillybos"
licence: "MIT"
language: "Python"
---

## What it is for
Expand Down
5 changes: 5 additions & 0 deletions site/content/translit.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ title: "Transliteration and cross-script search"
kicker: "Open source"
standfirst: "A small library that tells you which script a text is in, writes it in Latin letters by a named library standard, and reduces every spelling of a name to one form, so that one search finds them all."
description: "tetrak-translit: open-source detection, transliteration and search folding for Armenian, Georgian, Russian and Syriac, with ALA-LC, ISO and national romanisation schemes. MIT licensed."
software:
name: "tetrak-translit"
repository: "https://github.com/scattercode/tetrak-translit"
licence: "MIT"
language: "Python"
---

## What it is for
Expand Down
13 changes: 8 additions & 5 deletions site/layouts/_default/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@
term.html is the case that forced it: a tag page's .Title is the tag,
and a browser tab reading "ocr" says nothing about what is in it. */ -}}
<title>{{ block "title" . }}{{ if .IsHome }}{{ .Site.Title }}{{ else }}{{ .Title }} · {{ .Site.Title }}{{ end }}{{ end }}</title>
{{- /* The standfirst is the sentence a page already writes to say what it is,
so an article with one does not need a second copy in `description`.
Falling straight through to the site description put the same
paragraph about OCR routing under every result. */ -}}
<meta name="description" content="{{ with .Description }}{{ . }}{{ else }}{{ with .Params.standfirst }}{{ . }}{{ else }}{{ .Site.Params.description }}{{ end }}{{ end }}">
{{- /* Resolved in a partial because the share card and the structured data
publish the same sentence, and the three must not drift apart. */ -}}
<meta name="description" content="{{ partial "description.html" . }}">

{{- /* The theme is read and applied before first paint, so a reader who
chose dark never sees a flash of the paper ground. Inline and tiny by
Expand Down Expand Up @@ -62,6 +60,11 @@
{{- errorf "baseof: no page at /articles -- the feed link cannot be built" }}
{{- end }}

{{- /* How the page looks when its link is shared, and what it is in the
terms a search engine reads. Each partial says why it is there. */ -}}
{{- partial "social.html" . }}
{{- partial "structured-data.html" . }}

{{- /* Plausible, matching scattercode.dev and velostevie: no cookies, no
consent banner, and both requests same-origin. The src is the
first-party path proxied by functions/js/script.js.js at the
Expand Down
19 changes: 19 additions & 0 deletions site/layouts/partials/description.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{{- /*
The one-sentence description of a page, returned so that a caller can write
{{ $d := partial "description.html" . }}.

Three places publish it -- the meta description, the share card and the
structured data -- and they have to say the same thing: a search result that
describes a page one way and a link preview that describes it another reads
as two different pages.

`description` wins where a page has one. Otherwise the standfirst is the
sentence a page already writes to say what it is, so an article with one
does not need a second copy in `description`. Falling straight through to
the site description put the same paragraph about OCR routing under every
search result.
*/ -}}
{{- $description := .Site.Params.description }}
{{- with .Params.standfirst }}{{ $description = . }}{{ end }}
{{- with .Description }}{{ $description = . }}{{ end }}
{{- return $description }}
23 changes: 23 additions & 0 deletions site/layouts/partials/share-card.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{{- /*
The site's share card, returned as an image resource so that a caller can
write {{ $card := partial "share-card.html" . }} and read .Permalink, .Width
and .Height from it.

One card for every page. It is drawn by scripts/render-share-card.mjs from
the design tokens and the home page's standfirst, and committed; see that
script for why neither illustration in assets/images/design/ could do the
job.

Not fingerprinted, unlike the stylesheet and the script. A link preview is
fetched once by somebody else's server and kept, so the address has to stay
where it was when the link was shared.

A missing file fails the build, the same bargain the figure and lightbox
shortcodes make: a share card that 404s shows as a broken image in every
timeline the link reaches, and nothing on the site itself would look wrong.
*/ -}}
{{- $card := resources.Get "images/design/share-card.png" }}
{{- if not $card }}
{{- errorf "share-card: assets/images/design/share-card.png is missing -- run node scripts/render-share-card.mjs" }}
{{- end }}
{{- return $card }}
63 changes: 63 additions & 0 deletions site/layouts/partials/social.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{{- /*
What a link to this page looks like when it is shared: the Open Graph tags
that Mastodon, Bluesky, LinkedIn, Slack and most chat clients read to draw a
preview card.

The site had none until November 2026, so a shared article arrived as a bare
URL -- for a site whose readers mostly come by somebody passing a link on.

The title is the page's own, without the " · Tetrak" suffix the browser tab
carries: og:site_name says whose page it is, and a card that repeats the
name in the title wastes the line. A tag page is the exception baseof.html
and term.html already make. Its .Title is the bare tag, and a card titled
"ocr" says as little as a tab reading "ocr" did. The wording here has to
stay in step with the h1 in layouts/term.html.

Twitter gets one tag. It falls back to og:title, og:description and og:image
for everything else, and a second copy of each would be three more places
for the card to disagree with itself.
*/ -}}
{{- $description := partial "description.html" . }}
{{- $card := partial "share-card.html" . }}

{{- $title := .Title }}
{{- if .IsHome }}
{{- $title = site.Title }}
{{- else if eq .Kind "term" }}
{{- $title = printf "Tagged %s" .Title }}
{{- end }}

{{- /* Only an article is an "article" to Open Graph: dated, signed and
tagged. A product page or a reference page is a page of a website. */ -}}
{{- $isArticle := and .IsPage (eq .Section "articles") }}

<meta property="og:site_name" content="{{ site.Title }}">
<meta property="og:locale" content="en_GB">
<meta property="og:type" content="{{ if $isArticle }}article{{ else }}website{{ end }}">
<meta property="og:title" content="{{ $title }}">
<meta property="og:description" content="{{ $description }}">
<meta property="og:url" content="{{ .Permalink }}">
<meta property="og:image" content="{{ $card.Permalink }}">
<meta property="og:image:type" content="{{ $card.MediaType.Type }}">
<meta property="og:image:width" content="{{ $card.Width }}">
<meta property="og:image:height" content="{{ $card.Height }}">
{{- /* The card is the site's name over the home page's standfirst, so that
sentence is what it says to a reader who cannot see it. */ -}}
{{- with site.Home.Params.standfirst }}
<meta property="og:image:alt" content="{{ . }}">
{{- end }}
{{- if $isArticle }}
<meta property="article:published_time" content="{{ .Date.Format "2006-01-02" }}">
{{- /* .Lastmod is the file's last commit (enableGitInfo). An article is
often committed before the date it carries, and a page modified
before it was published is a claim nobody should have to parse.
Compared as days, because .Date is midnight and a commit made later
on publication day would otherwise count as a revision. */ -}}
{{- if gt (.Lastmod.Format "2006-01-02") (.Date.Format "2006-01-02") }}
<meta property="article:modified_time" content="{{ .Lastmod.Format "2006-01-02" }}">
{{- end }}
{{- range .Params.tags }}
<meta property="article:tag" content="{{ . }}">
{{- end }}
{{- end }}
<meta name="twitter:card" content="summary_large_image">
115 changes: 115 additions & 0 deletions site/layouts/partials/structured-data.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
{{- /*
schema.org structured data, as JSON-LD: what a page is, said in the form a
search engine reads rather than infers.

Three kinds of page get a block, and the rest get none. A block that only
repeated the title and the description would say nothing the <head> has not
already said.

- The home page says who publishes the site: an Organization, and the
WebSite it publishes.
- An article is a TechArticle: dated, signed, and published by that
organisation. The author comes from the same register as the byline
(partials/author.html), so the name a search engine reads is the name on
the page.
- A product page is a SoftwareSourceCode: a named package, its repository
and its licence, from the `software` map in its front matter.

None of this earns a rich result. Search engines draw those for recipes and
reviews, not for libraries. It is here so that the four packages, the
articles and the name "Tetrak" are tied to one another by statement rather
than by guesswork.

Each block is built as a dict and written by jsonify, never assembled as a
string: jsonify escapes whatever a title or a standfirst contains, including
the "</script>" that would otherwise end the block early.
*/ -}}
{{- $home := site.Home.Permalink }}
{{- $description := partial "description.html" . }}
{{- $locale := site.Language.Locale | default "en-gb" }}

{{- /* The organisation is named once and referred to by @id everywhere else,
so an article does not carry a second, thinner copy of it. */ -}}
{{- $orgID := printf "%s#organisation" $home }}
{{- $orgRef := dict "@type" "Organization" "@id" $orgID "name" site.Title "url" $home }}

{{- $schema := dict }}

{{- if .IsHome }}
{{- $org := merge $orgRef (dict "description" site.Params.description) }}
{{- /* Only the profiles that are Tetrak's and nothing else's. The GitHub
organisation in params.org holds other projects as well, so it is not
"the same as" Tetrak in the sense sameAs means. */ -}}
{{- with site.Params.profiles }}
{{- $org = merge $org (dict "sameAs" .) }}
{{- end }}
{{- $website := dict
"@type" "WebSite"
"@id" (printf "%s#website" $home)
"name" site.Title
"url" $home
"description" $description
"inLanguage" $locale
"publisher" (dict "@id" $orgID) }}
{{- $schema = dict "@context" "https://schema.org" "@graph" (slice $org $website) }}

{{- else if and .IsPage (eq .Section "articles") }}
{{- $author := partial "author.html" . }}
{{- $person := dict "@type" "Person" "name" $author.name }}
{{- /* The LinkedIn profile is the one address that is this author's alone.
The about page holds both of us, and two people sharing a URL is two
people a search engine may merge. */ -}}
{{- with $author.linkedin }}
{{- $person = merge $person (dict "sameAs" (printf "https://www.linkedin.com/in/%s/" .)) }}
{{- end }}
{{- $card := partial "share-card.html" . }}
{{- $schema = dict
"@context" "https://schema.org"
"@type" "TechArticle"
"headline" .Title
"description" $description
"url" .Permalink
"mainEntityOfPage" .Permalink
"inLanguage" $locale
"datePublished" (.Date.Format "2006-01-02")
"author" $person
"publisher" $orgRef
"image" $card.Permalink }}
{{- /* The same guard, for the same reason, as article:modified_time in
partials/social.html. */ -}}
{{- if gt (.Lastmod.Format "2006-01-02") (.Date.Format "2006-01-02") }}
{{- $schema = merge $schema (dict "dateModified" (.Lastmod.Format "2006-01-02")) }}
{{- end }}
{{- with .Params.tags }}
{{- $schema = merge $schema (dict "keywords" (delimit . ", ")) }}
{{- end }}

{{- else if isset .Params "software" }}
{{- /* Every key is required. A package with no repository or no licence is
not something to describe to a search engine by halves, and the build
failing here is how a fifth product page finds out what it owes. The
guards are chained so that one defect gives one message. */ -}}
{{- $software := .Params.software }}
{{- $missing := "" }}
{{- range slice "name" "repository" "licence" "language" }}
{{- if and (not $missing) (not (index $software .)) }}{{ $missing = . }}{{ end }}
{{- end }}
{{- if $missing }}
{{- errorf "structured-data: %q has a `software` map with no `%s` -- it needs name, repository, licence (an SPDX identifier) and language" .File.Path $missing }}
{{- else }}
{{- $schema = dict
"@context" "https://schema.org"
"@type" "SoftwareSourceCode"
"name" $software.name
"description" $description
"url" .Permalink
"codeRepository" $software.repository
"programmingLanguage" $software.language
"license" (printf "https://spdx.org/licenses/%s" $software.licence)
"publisher" $orgRef }}
{{- end }}
{{- end }}

{{- with $schema }}
<script type="application/ld+json">{{ . | jsonify | safeJS }}</script>
{{- end }}
16 changes: 16 additions & 0 deletions site/layouts/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{- /*
Hugo's built-in robots.txt is a single "User-agent: *" line. That allows
everything, which is what the site wants, but it leaves out the one thing a
crawler reads this file to find: where the sitemap is. A crawler that has
never been told about the site in a webmaster console has no other way to
learn it.

The empty Disallow is the standard way to say "nothing is off limits". The
first version of the protocol requires at least one rule per group.

No leading slash on the path: see "the baseURL trap" in the design skill.
*/ -}}
User-agent: *
Disallow:

Sitemap: {{ "sitemap.xml" | absURL }}
Loading