The glossary page
Write the glossary as sections by letter, each holding a <dl>. Give every <dt> an id so prose can link to it. This is a complete page without script. Wrapping it in <glossary-index> adds a filter box above the list and marks the current letter in the jump row as the reader scrolls.
<glossary-index placeholder="Filter terms..."> <h1>Glossary</h1> <nav class="glossary-jump" aria-label="Jump to letter"> <ol class="inline"> <li><a href="#glossary-p">P</a></li> <li><a href="#glossary-s">S</a></li> </ol> </nav> <section class="glossary-section" id="glossary-p"> <h2>P</h2> <dl> <dt id="term-proving"><dfn>proving</dfn></dt> <dd>The final rise of shaped dough before it is baked.</dd> </dl> </section> <section class="glossary-section" id="glossary-s"> <h2>S</h2> <dl> <dt id="term-starter"><dfn>starter</dfn></dt> <dd>A culture of flour and water kept alive to raise bread.</dd> </dl> </section></glossary-index>
Add the permalinks attribute to give each term a link that copies its address. It is off by default, since most readers arrive at a term and do not need to share it.
Which component
| <glossary-index> | <glossary-wc> |
| You write |
The whole page: jump row, letter sections, lists |
One flat <dl>, or a JSON file named in src |
| It builds |
The filter box only. Your structure stays as written. |
The heading, category groups, alphabet navigation and, with searchable, a search box |
| Use it for |
A site's main glossary page, where the markup comes from a template and should be complete without script |
A glossary inside another page, such as a project's terms, grouped by category |
<glossary-wc data-title="Bakery terms" searchable> <dl> <div data-category="Dough" data-term-id="autolyse"> <dt>Autolyse</dt> <dd>Resting flour and water before adding salt and starter.</dd> </div> <div data-category="Baking" data-term-id="oven-spring"> <dt>Oven spring</dt> <dd>The fast rise in the first minutes of baking.</dd> </div> </dl></glossary-wc>
Terms in prose
<dfn> marks the place where a term is defined, not every place it is used. In an article, that is the first use that explains the term. Link it to the glossary entry so a reader can get the full definition.
<p>Leave the shaped loaf for its final <dfn><a href="/glossary/#term-proving">proving</a></dfn>, the last rise before baking.</p> <p>A cold kitchen slows <a href="/glossary/#term-proving">proving</a> by hours.</p> <p>Bakers write <abbr title="desired dough temperature"><a href="/glossary/#term-ddt">DDT</a></abbr> on the mixing sheet.</p>
- Use
<dfn> once per term per page. Later mentions are plain links.
- Link a term when you mean the glossary's sense of it, not every time the word appears. One or two linked terms in a paragraph is enough.
- Do not link a term inside a heading, inside
<code> or <pre>, or inside another link.
- For a short form, wrap the link in
<abbr> with the full term in title.
When the reader follows the link, the glossary scrolls to the entry, and the term and its definition are tinted with a bar on the leading edge so the reader can see which entry they landed on.
How this site does it
The rest of this page describes this documentation site's build. None of it is in the vanilla-breeze package. It is here for people who write for this site, and as one worked design for a larger glossary.
One vocabulary file
Every term lives in site/src/_data/vocabulary.json as a SKOS concept with an @id, a skos:prefLabel, a skos:definition and optional skos:altLabel entries. The build makes three things from it: the glossary page, where each entry has the id term-{@id}; a /definitions.json file; and the topic pages. To add a term, add it to that file and rebuild.
The data-concept attribute
A term link on this site carries data-concept with the concept's @id.
<dfn><a href="/glossary/#term-progressive-enhancement" data-concept="progressive-enhancement">progressive enhancement</a></dfn>
A small script that the build writes looks for a[data-concept]. On a plain click it shows the definition in a native popover beside the term, fetching /definitions.json once and keeping it for the browser session. A click with a modifier key, or a middle click, follows the link as usual. So does every click in a browser without the Popover API, and a click on a term whose entry is on the current page.
Automatic linking
A build plugin links terms for you on the Architecture, Content Management, Extensibility, Interaction and Process guides and on the element, attribute, pattern, integration and snippet pages. You do not need to write term links by hand on those pages.
- The first occurrence of a concept's preferred label is wrapped in
<dfn><a data-concept>. Later occurrences get a plain link.
- At most one link is added per paragraph, list item, table cell or definition.
- Text inside links, code, headings,
<dfn>, <abbr>, code blocks and demo windows is never touched.
- Alternative labels are not linked unless the concept opts in with
"vb:autoLink": { "altLabel": true } in the vocabulary file. This keeps common words such as review
from being linked everywhere.
| To stop automatic linking | Write |
| On a whole page | autolink: false in the front matter |
| In one part of a page | data-no-glossary on an element around it |
| For one concept on a page | A link with that data-concept by hand, anywhere on the page. Yours is kept and no others are added. |
If a page is about a concept, list the concept in the page's concepts front matter as well. That writes the <meta name="concept"> tag described in Page Metadata.