Map component
Shipped in OINK v1.7.0, documented in the Map guide, and governed by the Components contract. Shared decisions are in the overview.
| Record | Value |
|---|---|
| Status | Accepted and shipped in OINK v1.7.0 (implemented 2026-11-27) |
| Owner | OINK maintainers |
| Delivery stage | S5; photo pins from GPS metadata later |
| Form | Data fence: ```map with a YAML or JSON list of places |
| New public API | The map fence and its fields; configuration params.map |
| Runtime | None by default; vendored Leaflet through content-components.js when maps are enabled |
| Affected surface | layouts/_markup/render-codeblock-map.html, scripts.html, content-components.js, VENDOR.json, a stylesheet layer, the configuration schema, three locale keys, a new guide at /docs/components/map/ |
Summary
HTML, Print and RSS render a numbered list with names, notes, thumbnails and OpenStreetMap coordinate links. Markdown and LLMS preserve the authored fence. When a site enables maps and names its tile service, an interactive map with matching numbered markers appears above the list in HTML. Nothing is enabled, and no tile service is chosen, by default.
Problem
Travel writing, photo essays and Expo pages, event and office locations, field trips, and site visits need places on a map. Authors use screenshots (static, no links, stale), Google Maps iframes (API keys, billing, terms, regional blocking, third-party scripts), or nothing. OINK has no way to say “these places, in this order” that also survives Print, feeds, and agents.
Design principles
- The list is the content; the map enhances it. A reader without the map (Print, RSS, no JavaScript, a blocked tile host) gets the same places, in the same order, with working links.
- Network only after complete configuration. Tiles are third-party requests from the reader’s browser. As with Draw.io, the theme ships no default server and stays off until configured (architecture contract).
- The site chooses the tile service. Tile services have usage policies, quotas, keys, and attribution terms. A theme default would make that legal and operational choice for every site.
- One form. A fence holds one place as easily as twenty; there is no second shortcode.
- WGS 84 coordinates. The system used by GPS, photo metadata, and OpenStreetMap.
Goals and non-goals
Goals
- A static list in HTML, Print and RSS and the original place data in Markdown and LLMS, with zero configuration.
- An opt-in interactive map: numbered markers, popups with name, note, thumbnail, and link, an optional route line, and dark tiles when provided.
- No page scroll hijacking, keyboard operation, and localized controls.
- Vendored engine, loaded only on pages that need it.
Non-goals
- Google Maps, Mapbox SDKs, or any API-keyed engine bundled by the theme.
- A theme-chosen default tile service.
- A single-point
mapshortcode, named tile styles, custom marker icons or tones, or a static fallback image parameter in the first stage. - GPX or GeoJSON tracks, clustering, search, routing, or geocoding.
- Coordinate transforms for GCJ-02 or BD-09 tiles (see limitations).
- Map tiles or images generated at build time.
Proposed behavior
Places
The fence body is a YAML or JSON list. Each item:
| Field | Rule | Invalid input |
|---|---|---|
name |
Required, plain text | Item skipped with a warning |
lat |
Required number, −90 to 90 | Item skipped with a warning |
lng |
Required number, −180 to 180 | Item skipped with a warning |
text |
Optional plain text | — |
image |
Optional image through the shared image resolver; a local raster is resized for the list and popup | Unresolvable: warns, no thumbnail |
link |
Optional URL through the shared URL policy; a same-page #anchor is the common case |
Invalid: warns and is dropped |
Unknown fields warn. A fence with no valid place warns and renders nothing.
Explicit lat/lng keys avoid the latitude/longitude order confusion of
GeoJSON’s [lng, lat] arrays.
Fence attributes
| Attribute | Rule |
|---|---|
caption |
Plain text figure caption |
route |
true connects places in list order with a line |
zoom |
Integer 1–22 (implemented range; drafted as 1–19). Default: 15 for one place; fit all places otherwise |
height |
A positive px, rem, em, vh or vw length; a percentage or zero warns and keeps the default, a responsive frame capped below the viewport height |
id |
Validated element ID |
tab, group, value |
The shared adjacent-tab behavior; the map resizes when its panel is shown |
num is not supported, as for other diagram fences; wrap the fence in fig
when a Book number is needed.
Static form
HTML, Print and RSS use this static list.
Coordinates are shown as authored. The OpenStreetMap link is an ordinary outbound link, not a request.
Configuration
enable: true with a missing or invalid tiles or attribution warns and
leaves maps off. The guide shows configuration examples — OpenStreetMap’s
standard tiles (light use under the OpenStreetMap Foundation tile usage policy,
attribution required), a commercial service with a domain-restricted key, and a
self-hosted server — without making any of them a default. A key in a tile URL
is public; the guide says so.
Interactive map
When params.map is complete and the output is HTML:
- The figure gains a canvas and a JSON copy of the validated places;
hasMapselects thecontent-components.jsadapter and registers theleafletengine indata-td-component-engines. Leaflet’s stylesheet is linked only on those pages, as the Asciinema player’s is. - The adapter mounts each map within 320px of the viewport, like the other engines.
- Markers are numbered HTML markers matching the list numbers, styled with preset tokens; no marker images.
- Popups are built with DOM APIs (
textContent, element creation) from the JSON: name, note, thumbnail, link. NoinnerHTML. - Scroll-wheel zoom is off, so reading never zooms the map. Zoom buttons, keyboard control, and pinch remain. On narrow screens the frame stays shorter than the viewport so the page can always be scrolled past.
- With
dark_tiles, tiles follow the color scheme; without it, light tiles stay (no color inversion of map imagery). - Size is recomputed on resize, when a tab panel is shown, and when a disclosure opens.
- Attribution uses Leaflet’s attribution control with the configured text.
- If the engine or tiles fail, the canvas hides and the list remains.
The list stays visible under the map as its legend and as the accessible alternative.
Outputs
| Output | Result |
|---|---|
| HTML, maps off | Static form only; no canvas, script, or tile URL |
| HTML, maps on | Map above the static form |
| Browser print | Print rules hide the canvas; the list prints |
| Dedicated Print | Static form |
| Markdown / LLMS | The authored fence |
| RSS | Static form with absolute thumbnail URLs |
Engine
Leaflet (BSD-2-Clause) is small, needs no WebGL, and supports HTML markers and
keyboard control. On 2026-11-27 npm lists 1.9.4 as latest and 2.0 in beta
(2.0.0-beta.5, 2026-11-19). Vendor the current stable release at
implementation time, with license, version, source, and checksums in
VENDOR.json. If 2.0 is stable by then and is distributed only as an ES
module, the engine loader (a classic script with a readiness check) needs a
matching change first.
MapLibre GL with vector tiles or a single PMTiles file on object storage is the stronger long-term route to self-hosted maps, at a larger size and with WebGL. The fence format is engine-neutral, so a later proposal can switch or add an engine without changing content.
Photo pins from GPS metadata
A place with a local photo and no coordinates could take its position from the photo. Verified on Hugo 0.170.1:
Image.Exifwas deprecated in Hugo 0.155 and is now removed.Image.MetareturnsLat/Longonly when the site’simaging.meta.fieldsincludes the GPS fields. Hugo’s default field filter excludes GPS, and a theme cannot change a site’simagingconfiguration.- Published original photos keep their GPS data unless stripped, which can reveal private locations.
This is therefore a later stage: explicit coordinates first, then GPS-derived pins as a documented site opt-in with a privacy note.
Accessibility and privacy
The numbered list conveys everything the map does. Map controls get localized names. Tile requests send the reader’s IP address and the viewed area to the tile service, only after the site enables maps and only when a map comes into view.
Limitations
Coordinates are WGS 84. Map services in mainland China commonly use GCJ-02 (or
BD-09), so WGS 84 markers on those tiles appear offset by hundreds of meters.
The first stage documents this and supports only WGS 84 tiles. A later
params.map option could convert markers for GCJ-02 tiles if a site needs it.
Trade-offs and alternatives
| Option | Decision | Reason |
|---|---|---|
| Google Maps | Rejected | Keys and billing, terms that restrict caching, regional blocking, third-party scripts |
First-draft single-point {{< map >}} shortcode |
Removed | A second form for what a three-line fence expresses |
| CARTO light/dark tiles as the default | Removed | A commercial service with its own usage terms; the theme should not choose it for every site |
styles, center, marker icon and tone, fallback image, full |
Removed for now | Numbered markers tie the map to the list; a fallback image duplicates the list |
| Hiding the list when the map mounts | Rejected | The list is the legend, the accessible alternative, and the print form |
| Static map images rendered at build | Rejected | Needs tiles at build time, contradicting offline builds |
| Click-to-load maps | Shipped as loading: click |
Lazy loading on approach is the engine norm and stays the default; params.map.loading: click waits for an explicit button where privacy review or touch scrolling demands it |
Costs: a vendored engine to maintain, a configuration step before any map appears, and no default look out of the box. These follow directly from the network policy.
Compatibility
Additive. map is a new fence language and params.map a new key. With maps
off, a page with a map fence is fully readable.
Implementation plan
- Vendor Leaflet under
assets/third_party/leaflet/withVENDOR.jsonentries. render-codeblock-map.htmlwith a parse partial (validation, thumbnails via the image resolver and processing), static form, and enabled form.params.mapinhugo.yaml, the resolver with Draw.io-style completeness warnings,bin/check-params.py, and the generated configuration schema.- A
leafletadapter incontent-components.js;scripts.htmlengine and stylesheet registration; unit tests with a stubbed engine. - Locale keys in all 32 files:
ui_map_labelandui_map_open_osm; the zoom controls reuseui_diagram_zoom_inandui_diagram_zoom_out. - Fixtures: maps off and on, one and many places, invalid places, route,
thumbnails from each source kind, tabs, and each output. Owning checks:
check-components.py(data fences),check-runtime-isolation.py,check-vendor.py,check-output.py,check-output-security.py,check-goldens.py,check-stylesheets.py,check-params.py,check-i18n.py,node --test. - Browser review on this site with a configured tile service: keyboard, touch scrolling, dark tiles, tabs, presets, print.
Acceptance criteria
- With maps off, no output contains a tile URL, the Leaflet script, or its stylesheet.
- With incomplete configuration, the build warns and behaves as maps off.
- The list is identical with maps on and off.
- Scroll-wheel input over a map scrolls the page.
- Popups contain no author HTML.
Open decisions
- List presentation under the map. Recommended: always visible, compact. Alternative: collapsible for long lists.
- Marker style. Recommended: numbers only in S5; icons later on request.
- Engine version. Recommended: decide between 1.9.4 and 2.x when S5 starts.
- GCJ-02 support. Recommended: out of scope until a site asks.
Decision log
- 2026-11-27 (first draft).
mapfence plus single-point shortcode, CARTO default tiles, named styles, marker icons and tones, fallback images, and EXIF pins in C3. - 2026-11-27 (review). One fence; no default tile service; the list is
always rendered; EXIF pins moved to a later stage after verifying Hugo’s
Image.Metadefaults. - 2026-11-27 (implementation). Implemented with vendored Leaflet 1.9.4 (
VENDOR.json),render-codeblock-map.html,content/map-config.html, aleafletadapter incontent-components.jsandassets/css/td/map.css. Differences from this draft: the fence is parsed as YAML by resource name, because Hugo’s content sniffing reads a YAML list written as- {name: …}as JSON; the zoom controls reuseui_diagram_zoom_inandui_diagram_zoom_out, so onlyui_map_labelandui_map_open_osmare new;params.mapis validated on every page. Invalid input is covered inbin/check-content-primitives.pyandbin/check-params.py;tests/js/content-components-map.test.jscovers the adapter. - 2026-11-27 (review hardening). Fixed
{s}subdomain tile validation and YAML.nancoordinate build crash; raised selector specificity inmap.cssto outrank body-endleaflet.css, aligned popups/controls/focus rings across all four presets and dark mode, fixed popup close-button overlap, dark-mode print ink,slatedark--td-on-link, RTL popup/coordinate direction, forced-colors popup border, and print pagination; added touch single-finger scroll pass-through,keyboard-nav.jsmap-focus yield, complete tile-failure canvas hiding,prefers-reduced-motionsupport, markeraria-label,Escapepopup dismissal, localized close label,tabs.js-first ordering for hidden tabs, list-click panning, andrich-copy.jscanvas exclusion; added optionalattribution_url(OSM copyright link compliance),subdomains, andloading: click(32-localeui_map_load), plus Playwright regression coverage intests/browser/map.spec.mjs. - 2026-11-27 (adversarial review). A non-string
params.map.loading(a list or map) stopped the build, becausecondevaluatedstrings.TrimSpaceon it; it now warns and keepslazy. Tile templates may use only{s},{z},{x},{y},{-y}and{r}: any other placeholder, in the host, path or query, warns at build time, since Leaflet throws on one it cannot fill and left an empty map. When every first tile fails, the map is removed only after Leaflet finishes dispatching the layer’sload, which otherwise threw aTypeError; failingdark_tilesfall back to the dimmed light tiles instead of removing the map for good. Theloading: clickbutton names every host the map may contact,{s}as*and thedark_tileshost included.tests/browser/map.spec.mjsruns intest:content-components. Minor follow-ups: a pen drags the map like a mouse; a popup opened with Enter takes focus and returns it to its marker when closed from inside; a load button activated from the keyboard hands focus to the map;params.map.subdomainsis documented as empty by default (Leaflet’sabc);ui_map_loadreads “Завантажити мапу” in Ukrainian and “טעינת המפה” in Hebrew.