Pudu programming language
Menu
Package

@chrismichaelps / pudu-lang-docgen

Documentation publishing for Pudu: articles, API references, navigation, search, and static websites

0.1.0Apache-2.01

InstallClose

templates.md

Markdown220 lines9.1 KB

GitHub ↗

Templates and theming


uid: guides.templates description: Control the look of a site with page metadata, template folders, partial overrides, styles, scripts, and alert titles.


Every page is rendered through a template: a layout with partials for the header, sidebar, footer, and other regions. The built-in default template provides a responsive layout with light, dark, and automatic color themes, a searchable header, a filterable sidebar, an outline of the current article, and print styles. Most sites need only metadata and a stylesheet to make it their own.

Page metadata

Set these keys in build.globalMetadata for the whole site, in fileMetadata for groups of files, or in an article's front matter for one page.

Site identity

KeyDescription
_appTitleAdded to every browser tab title after a vertical bar.
_appNameThe name next to the logo. Defaults to _appTitle.
_appLogoPathThe logo image in the header.
_appLogoUrlWhere the logo links. Defaults to the site's home page.
_appFaviconPathThe browser tab icon.
_appTouchIconPathThe icon used when the site is added to a home screen.
_appFooterHTML for the footer. Only safe elements and attributes are kept. When set, it replaces the footer below.
_footerLinksFooter links as a list of objects with name and href. Unsafe or incomplete entries are left out.
_copyrightThe copyright holder shown in the footer as © <year> <holder>, dated by the year of the build.
_themeColorThe browser interface color on supporting devices.
_langThe page language, such as en. It also selects the interface text language.

Layout and parts

KeyDescription
_layoutdefault, landing (no sidebar, outline, breadcrumb, or pager; full-width content), or chromeless (no header or footer).
_disableTocHide the sidebar.
_disableAffixHide the In this article outline.
_disableBreadcrumbHide the breadcrumb trail.
_disableNavbarHide the top navigation.
_disableFooterHide the page footer.
_disableTocFilterHide the sidebar filter box.
_disableNextArticleHide the previous and next links.
_disableContributionHide the Edit this page link.
_enableSearchfalse hides the search box and skips the search index.
_enableNewTabOpen external links in a new tab.
_appStyle, _appScriptAnother stylesheet or script for every page.
_mathScript, _mermaidScriptReplace the script loaded on pages with math or diagrams.
_textReplacement interface text, such as { "edit": "Suggest a change" }.

Search engines and sharing

KeyDescription
descriptionThe page summary for search results and link previews.
keywordsText or a list of keywords.
authorThe page author.
_baseUrlThe site's public address. Enables canonical links, absolute preview images, and structured breadcrumb data.
_appOgImagePath, imageThe preview image for shared links; image sets it for one page.
_twitterSiteThe account named in link previews.
_noindexAsk search engines not to index the page, and leave it out of the search index and sitemap.
_metaExtra <meta> tags as name and content pairs.
_googleAnalyticsTagIdAdds the analytics tag for that identifier.

This site's identity is set entirely through globalMetadata:

"globalMetadata": {
  "_appTitle": "Pudu Docgen",
  "_appName": "Pudu Docgen",
  "_appLogoPath": "images/pudu-lang-short.png",
  "_appFaviconPath": "images/pudu-lang-short.png",
  "_baseUrl": "https://www.pudu-lang-docgen.com",
  "_enableSearch": true,
  "_lang": "en"
}

Landing pages

A YAML file whose first line contains YamlMime:Landing becomes a hub page on the landing layout: a banner across the full width of the page, then highlighted entry points, topic lists, and related links. Addresses are checked like links in articles, so a missing page is reported.

### YamlMime:Landing
title: Inventory service documentation
summary: Everything needed to run and extend the inventory service.
metadata:
  uid: home
  description: Guides and reference for the inventory service.

highlightedContent:
  items:
  - title: What is the inventory service?
    itemType: overview
    url: guide/introduction.md
  - title: Release notes
    itemType: whats-new
    url: https://example.org/releases

conceptualContent:
  title: Explore
  items:
  - title: Operate
    links:
    - text: Deploying
      url: guide/deploy.md
    footerLink:
      text: All operations guides
      url: guide/index.md

additionalContent:
  sections:
  - title: Related content
    items:
    - title: Pudu
      summary: The language the service is written in.
      url: https://www.pudu-lang.org/
KeyDescription
titleThe banner heading and the page title. Required.
summaryThe text under the banner heading.
metadataPage metadata, like an article's front matter.
highlightedContent.itemsEntry points with a title, a url, and an itemType of overview, get-started, quickstart, concept, tutorial, how-to-guide, reference, whats-new, download, deploy, architecture, or sample.
conceptualContentAn optional title and items, each a topic with a title, a list of links with text and url, and an optional footerLink.
additionalContent.sectionsSections with a title and items, each with a title, a summary, and a url.

The banner colors come from the --hero-bg custom property, which a template's public/main.css can set.

Template folders

build.template lists templates in order. The first is usually default; the others are folders in the project. A later folder replaces files of an earlier one.

"template": ["default", "template"]

A template folder may contain:

FileEffect
layout.htmlReplaces the page layout.
partials/<name>.htmlReplaces or adds a partial.
public/main.cssLoaded on every page after the default styles.
public/main.jsLoaded on every page after the default script.
public/**Any other file, published under public/.
token.jsonReplacement alert titles.

The built-in partials are head, header, sidebar, breadcrumb, actions, affix, pager, footer, and scripts. Export them with the template command to start from the originals:

pudu run Docgen.pudu template export template

Styles and scripts

The default styles are written with CSS custom properties, so a small public/main.css can restyle the whole site. This site's stylesheet lays out the footer columns and the landing page using the theme's own colors:

.footer-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) repeat(3, minmax(160px, 1fr));
  gap: 32px;
}

.content a.button-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}
PropertyUsed for
--accent, --accent-hover, --accent-softLinks, active navigation, buttons.
--bg, --bg-subtle, --bg-muted, --bg-hoverPage, panel, and hover backgrounds.
--text, --text-muted, --text-subtleBody, secondary, and tertiary text.
--border, --border-strongRules and outlines.
--font, --font-monoText and code fonts.
--content-width, --sidebar-width, --affix-widthColumn widths.

Light values are set on :root. Dark values are set on :root[data-theme="dark"] and, for the automatic theme, on :root[data-theme="auto"] inside a prefers-color-scheme: dark media query; override both to change the dark theme.

Alert titles

token.json renames alert titles. Keys are alert kinds in lower case:

{ "note": "Remarque", "warning": "Avertissement" }

Layout syntax

Layouts and partials use a logic-less template syntax:

TagMeaning
{{name}}The value, HTML-escaped.
{{{name}}} or {{& name}}The value without escaping.
{{#name}}...{{/name}}Repeat for each item of a list, or show when the value is present and true.
{{^name}}...{{/name}}Show when the value is missing, false, or empty.
{{>name}}Include a partial.
{{! comment}}Ignored.

A layout that does not parse stops the build with DG401. Export the view of each page with --exportViewModel to see every value a layout can use, including title, body, toc, navbar, breadcrumb, headings, previous, next, editUrl, lastModified, and text.

Interface language

_lang selects the interface text of the default template. English, Spanish, French, German, Portuguese, Italian, Japanese, Chinese, and Korean are built in; other languages use English. Replace individual strings with _text:

KeyEnglish text
skipSkip to main content
searchSearch
filterFilter by title
updatedLast updated on
editEdit this page
previous, nextPrevious, Next
inThisArticleIn this article
pdfDownload PDF