Maps
map fence to get a numbered place list in HTML, Print and RSS, plus an interactive map once the site names a tile service.A map fence suits places that belong together in an order: the stops of a trip, a company’s offices, the venues of a conference, the sites of a field survey. HTML, Print and RSS show a numbered list with names, notes, thumbnails and OpenStreetMap coordinates. The list works without JavaScript. Markdown and LLMS keep the original YAML fence.
The interactive map above the list is something your site turns on. Map tiles
are images fetched from a third-party tile service in the reader’s browser,
and every service has its own usage policy, quota and attribution terms, so
the theme does not pick one for you: until you set params.map with a tile
URL and its attribution, as described in
Site configuration, pages show the list and make no map
requests at all.
For addresses that need no map, a table is enough; a map that is a drawing belongs in an image.
Shortest form
Each place needs a name, a lat and a lng.
- Forbidden City 39.9159, 116.3908
- Temple of Heaven 39.8822, 116.4066
- Summer Palace 39.9901, 116.2647
This site has a tile service configured, so a map appears above the list, with markers numbered like the list and zoomed to fit every place. On a site without one, the same fence renders only the list. Each coordinate pair links to the place on openstreetmap.org; that is an ordinary link the reader may follow, not a request the page makes.
The body is parsed as YAML, and since JSON is valid YAML,
[{"name": "Forbidden City", "lat": 39.9159, "lng": 116.3908}] works too.
Site configuration
Maps are off by default. To turn them on, choose a tile service and add it to
hugo.yml. This site uses OpenStreetMap’s standard tiles:
tilesis anhttps://URL template containing{z},{x}and{y}({s}for subdomains,{r}for high-DPI tiles and{-y}for TMS row order are allowed). Any other placeholder, such as{apikey}or{accessToken}, has no value to fill: write the key into the URL itself, or the template warns and is ignored. An optionaldark_tiles, with the same rules, is used in dark mode. Only{s}may vary in either host. Put tile coordinates in the path or query.attributionis the plain-text credit the tile service requires; it appears in the corner of every map. Addattribution_url(https://) to turn the credit into a clickable link without accepting author HTML — OpenStreetMap’s attribution guidelines require interactive web maps to link tohttps://www.openstreetmap.org/copyright.subdomainsoverrides Leaflet’s defaultabcwhentilesuses{s}(for exampleabcdor"01234567"). Quote digits: YAML reads an unquoted01234567as a number, which warns and falls back to Leaflet’s default.max_zoomis a whole number from 1 to 22 and defaults to 19.loadingislazy(the default: a map loads once it is on screen, within 320px below the viewport, or anywhere above the reading position) orclick(show a button naming every tile host the map may contact,dark_tilesincluded and{s}written as*, and send no tile requests until clicked; if the button still holds focus, it moves to the map on success or the first coordinate link on failure).enable: truewithout a validtilesand anattributionwarns and leaves maps off, so a half-finished configuration never sends readers to a service you have not agreed to. Fences keep rendering their lists.- Surrounding whitespace in
tiles,dark_tiles,attribution_urlandsubdomainsis trimmed. An unknown key warns and is ignored, including a camel-case spelling such asmaxZoom, which Hugo lowercases; writemax_zoom.
Pick a service that fits your traffic. The OpenStreetMap Foundation’s tile usage policy allows light use of its standard tiles with linked attribution; a busy site should use a commercial tile service with a domain-restricted key, or host its own tiles. A key in the tile URL is visible to every reader, which is why the restriction to your domain matters.
Each tile request sends the reader’s IP address and the area being viewed to
the tile service. Requests start only on sites that enable maps. Under the
default lazy loading they start as a map nears the viewport, and a reader who
opens a link to a later section loads every map above it at once, so the text
being read is not pushed down later. If no tile request may happen before the
reader agrees, set loading: click: nothing is requested until the button is
pressed. Either way, mention the service in your privacy notice if you have one.
Place fields
Besides name and the coordinates, a place can carry a note, a thumbnail and a
link:
nameandtextare plain text: Markdown and HTML in them show literally, and popups are built from this text, never from HTML.imageis resolved like any image: page resource, then global resource, then static path, then remote URL. Local raster images are resized to fit 480×360 for the list and the popup, and carry their width and height in both, so the popup keeps its size while the image loads; remote images are used as they are. Thumbnails are decorative (alt=""), since the name beside them already says what they show. The route map below uses four images stored beside this page’sindex.md.linkturns the name into a link in the list and in the popup, typically to a#anchoron the same page. Quote it, because YAML reads an unquoted#as the start of a comment.- A place without a name, without numeric coordinates, or with coordinates out
of range warns and is skipped. A quoted number such as
lat: "39.9159"is a string, so that place is skipped too. - Unknown fields warn and are ignored. A fence with no valid place, including
an empty list
[], warns and renders nothing.
Routes, thumbnails and captions
route=true joins the places with a line in list order, and image adds a
resized thumbnail to both the list entry and its marker popup. caption adds a
plain-text caption under the list, and screen readers announce it as the name
of the map.
- Forbidden City Start at the Hall of Supreme Harmony; close-up below. 39.9159, 116.3908

- Jingshan Park Climb Wanchun Pavilion to overlook the palace roofs. 39.9245, 116.3904

- Beihai Park Cross Yong'an Bridge toward the White Dagoba. 39.9264, 116.3825

- Drum Tower End the walk at the northern drum plaza. 39.9393, 116.3898

Select a marker or a row in the list below to open its popup with the thumbnail, the name and the note; the first place links to the next section. The route is a straight line from place to place, not a computed walking or driving route.
One place and zoom
A single place opens at zoom level 15. zoom sets another level, from 1 (the
whole world) to 22 (a street corner, capped by params.map.max_zoom), and
height sets the map’s height as a CSS length.
- Forbidden City Hall of Supreme Harmony, centered inside the palace moat. 39.9159, 116.3908

With several places, zoom replaces the fitted zoom level but keeps the
fitted center. Without height the map is min(26rem, 60vh) tall, so a reader
on a phone can always scroll past it. height takes a positive number
followed by px, rem, em, vh or vw. A percentage has no height to
resolve against and a zero height leaves nothing to see, so both, like anything
else, warn and keep the default.
The interactive map
- The theme bundles Leaflet 1.9.4. Only pages with a map link its stylesheet,
and the script loads when the first map is due: on screen, within 320px
below the viewport, or anywhere above the reading position (or when the
reader clicks the load button under
loading: click). - Scroll-wheel zoom is off, and on touchscreens single-finger swipes keep scrolling the page instead of trapping the reader inside the map. Readers pan and zoom with two-finger pinch, the zoom buttons, a mouse or pen drag, or the keyboard (focus the map, then use the arrow keys and + / -; site-wide single-key shortcuts yield while focus is inside the map).
- Selecting a marker by pointer or with Enter, or clicking a place entry in the list below, pans to the place and opens its popup. A popup opened with Enter takes focus, so its link and close button come next; Escape or the close button closes it and returns focus to the marker.
- In dark mode the map switches to
dark_tileswhen the site configures them, and switches back when the reader changes the color scheme; withoutdark_tiles, light tiles are gently dimmed without inverting map colors. If everydark_tilesrequest fails, the map keeps the dimmed light tiles. - The map resizes and frames with its container, including when a tab panel is shown or a disclosure opens, without fetching tiles for hidden tabs ahead of time.
- If Leaflet or all light tiles fail to load, the canvas hides and the list remains.
The list stays under the map as its interactive legend and accessible alternative, and it uses two columns on wide screens.
Coordinates
Coordinates are WGS 84 decimal degrees, the system used by GPS, photo metadata
and OpenStreetMap. The explicit lat and lng keys avoid the mix-ups that
GeoJSON’s [lng, lat] order causes. To look up a place, open it on
openstreetmap.org: the address bar ends with #map=zoom/lat/lng.
Tile services in mainland China commonly use GCJ-02 or BD-09 coordinates, on
which WGS 84 markers land hundreds of meters off. The theme does not ship
unofficial coordinate transforms; choose a WGS 84 / CGCS2000 tile service
(such as compliant self-hosted tiles, a global commercial provider, or Tianditu
with subdomains: "01234567" — note that Tianditu splits base imagery and
place labels into two separate layers while params.map.tiles configures one).
Output
Print and RSS show the list and the caption without a map, and RSS makes the
thumbnail URLs absolute. On a site without a tile service, the HTML page has
no map script, stylesheet or tile URL at all. The page’s Markdown output keeps
the map fence as you wrote it.
Parameter reference
Place fields:
Fence attributes:
zoom, ,- 1 to 22 (capped by
params.map.max_zoom). Without it: 15 for one place, otherwise fit all places tab, ,- Makes this map one panel of a tab set
num and other unknown attributes warn and are ignored. Hugo consumes
style and strips on* attributes before the theme sees the fence, so those
are ignored without a warning.
Site parameters (hugo.yml):
Limits
- Coordinates are WGS 84 only; markers on GCJ-02 or BD-09 tiles appear offset.
- Routes connect places directly in coordinate space and do not wrap across the antimeridian.
- There are no GPX or GeoJSON tracks, no marker clustering, search or geocoding, and no custom marker icons.
- Markers are not read from photo GPS metadata; write the coordinates.
name,textandcaptionare plain text; put rich text in a paragraph next to the fence.- Remote thumbnails are neither downloaded nor resized at build time.
Related
- Gallery — the photos from the places on the map
- Images — where thumbnails come from
- Tabs — one map per day of a trip
- Expo layout — photo essays and exhibitions
- Draw.io — another feature that stays off until the site names a service