Bring existing docs to Ascribe
Start a project in a folder of Markdown you already have, and take it from ascribe init to a clean ascribe check.
For AI agents: the documentation index is at llms.txt, and this page is available as Markdown.
Ascribe reads plain CommonMark, so a folder of Markdown is most of a project already. This guide starts a project around one, fixes what the first check finds, and shows what to rewrite in pages written for another tool: links, frontmatter, callouts, heading ids, components, and a copy of the docs for each version.
The pages here are examples/existing-docs: four pages in docs/, some with frontmatter and some without, and one link written to the .html file the old site published.
Before you start
- Install the command, as Getting started does.
- Commit the pages first, so that
git diffshows each change Ascribe makes.
Start the project
In the folder that holds docs/:
ascribe init
When the pages are in another folder, name it, from the folder you run init in: ascribe init --content-root guides. It’s the folder the pages are in, not the project’s own, so the build’s output stays out of it.
init writes ascribe.toml, counts the pages it found, and checks them:
wrote ascribe.toml
wrote ascribe.addresses, where a page's move is recorded, so the addresses it published keep working
found 4 pages in docs/; with no page types declared in ascribe.toml, no page needs `type:`
3 pages have no `title`; `ascribe check --fix` takes the opening heading as the title of 2 of them, and the rest need `title:` written in their frontmatter
`ascribe check` finds 4 errors, 0 warnings, 5 advice:
3 ASC048 frontmatter-missing-field (error)
3 ASC150 page-description-missing (advice)
2 ASC151 heading-level-skipped (advice)
1 ASC036 link-target-missing (error)
Next, run `ascribe check --fix`, which fixes 2 of them, then `ascribe check --code ASC048`
To put the advice off, so the check reports only what's new: `ascribe baseline write`
Then, to publish the pages as a site with Astro, read https://ascribed-dev.com/go/astro-guide/The ascribe.toml it writes for a folder of pages declares no page types. Every page is then of the one implicit type, page, and none of them has to say type: in its frontmatter. Each needs a title, and can have a description:
# The project's content model: where its pages are, and what each kind of
# page must say in its frontmatter. `ascribe check` and the editor read it.
# Every section is in the reference: https://ascribed-dev.com/go/content-model/
spec = "0.1"
[project]
# The folder the pages are in. A link that starts with `/` starts here.
content-root = "docs"
# What most projects add next:
#
# - A phrase, such as the product's name, written once here and on a page as
# {product}: https://ascribed-dev.com/go/phrases/
# - A dimension, such as the reader's platform, for content that's for some
# readers only: https://ascribed-dev.com/go/dimensions/
# - [consumer], the site the pages are published as, and its address:
# https://ascribed-dev.com/go/consumer/
# No page types: every page is of the one implicit kind, `page`, and names
# no type in its frontmatter. Each needs a `title`, and can have a
# `description`. Once a type is declared here, each page names its own, as
# `type: page`: https://ascribed-dev.com/go/content-model/
[frontmatter]
description = "string?"In an empty folder, init declares the type page instead, which each page names; ascribe init has both. --templates, which declares six types, is refused in a folder of pages, since each page would have to name one. Take the templates once the pages check clean, with ascribe templates eject, then give each page type:, since the project declares types from then on.
Fix what the check finds
-
Apply the safe fixes:
ascribe check --fix --format conciseA page with no
titlethat opens with a level-1 heading takes the heading as its title: the fix writes it in the frontmatter, and takes the heading out of the page, since the site shows the title in its place. Here that’sindex.mdandalerts.md. What’s left is listed, one line each, as--format conciseprints it; without it, the check shows each problem with its line and its help:ascribe 0.4.5fixed 1 problem in docs/guides/alerts.md fixed 1 problem in docs/index.md docs/guides/alerts.md:13: [ASC036] `../install.html` doesn't exist docs/guides/troubleshooting.md:1: [ASC048] the required field `title` is missing; the content type `page` needs it docs/guides/alerts.md:1: [ASC150] this page has no `description`; write a sentence saying what the page is for, which search results and agents show with its title docs/guides/troubleshooting.md:1: [ASC150] this page has no `description`; write a sentence saying what the page is for, which search results and agents show with its title docs/index.md:1: [ASC150] this page has no `description`; write a sentence saying what the page is for, which search results and agents show with its title ascribe.addresses:1: [ASC257] the addresses weren't compared with the base: `main` (880f4af4a43f) has no Ascribe project here, so it published nothing to keep checked 4 files for every build, 4 with problems: 2 errors, 0 warnings, 4 adviceA fix is safe only when it can’t change what the page says. A page whose opening heading something links to, as
#configure-alerts, isn’t given the heading as its title by--fix, since the link would lose its target; the fix is offered in the editor, for you to apply and fix the link. -
Give the other pages a title.
troubleshooting.mdopens with a paragraph, so it gets frontmatter:--- title: When a page doesn't load --- -
Fix the links. A link in Ascribe names the file it goes to, and each output writes its address, so
[Install Lantern](../install.html)becomes[Install Lantern](../install.md).ascribe check --code link-target-missinglists every link that names no file. -
Record the remaining advice in a baseline. Advice never fails the check: here it’s the pages with no
description, and one aboutascribe.addresses, which step 5 explains and the baseline leaves out. To deal with the rest later, and have the check report only what’s new, record it inascribe.baseline:ascribe baseline writeascribe 0.4.5wrote ascribe.baseline: 3 problems in 3 files, 3 added; commit it with the docsSee The baseline for what it baselines, and how it shrinks as you fix each.
-
Check again:
ascribe check --format conciseascribe 0.4.5ascribe.addresses:1: [ASC257] the addresses weren't compared with the base: `main` (880f4af4a43f) has no Ascribe project here, so it published nothing to keep checked 4 files for every build, 1 with problems: 0 errors, 0 warnings, 1 advice, 3 in the baselineNo errors are left. The one advice,
addresses-base-unreadable(ASC257), says the check compared nothing withascribe.addresses: the base it compares with has the pages and no project, so it published no address to keep. The base is where your branch leftmain, or, working onmain, its last commit. Its help is about CI, where a base can’t be read; here nothing is wrong.The baseline doesn’t cover it:
baseline writedoesn’t compare the addresses, so it never sees this advice, and doesn’t record it. The advice goes once the base has the project, as the next step shows. -
Commit
ascribe.toml,ascribe.addresses,ascribe.baseline, and the pages, and add.ascribe/to.gitignore. Committed onmain, the base then has the project, and the check is clean:ascribe check --format conciseascribe 0.4.5checked 4 files for every build, 0 with problems: 0 errors, 0 warnings, 0 advice, 3 in the baselineOn a branch, the base is still where the branch left
main, so the advice stays until the branch is merged, as it does in the pull request that brings the project in.
To check every pull request, see Check in CI.
What to rewrite in pages from another tool
The check finds the links and the frontmatter that need a change, and GitHub’s alerts, such as > [!NOTE], which github-alert reports and --fix rewrites as @note. It doesn’t find other tools’ callouts or heading ids: they’re text to Ascribe, so the site shows them as they’re written. Search for them:
grep -rnE '^(:::|!!! )|\{#[^}]*\}\s*$|\[\[' docs/
| Written as | In Ascribe |
|---|---|
[Install](install.html), [Install](/install/) |
[Install](install.md): the file. A published address is reported, and --fix rewrites it; an .html link is reported as missing, for you to rewrite. |
[[Install]], [[install|Install it]] |
[Install it](install.md) |
:::note … :::, !!! note |
@note, as @note: One line., or @note {type=warning}: … @end around several blocks |
> [!NOTE], > [!WARNING], and GitHub’s other alerts |
The @note of the same type. The check reports each, and --fix rewrites it, keeping the quote’s content |
## Setup {#setup} |
## Setup, with @id: setup on the line below it (@id) |
| A frontmatter key for the sidebar’s label | nav-label, which every page can have |
| A frontmatter key for the page’s place in the sidebar | ascribe.nav, which orders the pages and sections |
| Any other frontmatter key | A field in [frontmatter] in ascribe.toml, such as tags = "list(string)?", or nothing: a key ascribe.toml doesn’t declare is reported |
The callout types are note, tip, important, warning, and caution; [notes] in ascribe.toml declares others. Only .md files are pages: rename a .mdx file once its components are replaced, as the next section maps them, and keep a file that isn’t a page out of the content root, or in a folder whose name starts with ..
Components and versions from another tool
The check reports none of these either: an MDX component or a shortcode is text or raw HTML to Ascribe. Each one becomes a directive, a phrase, or a widget the project declares. examples/comparison has one page written four ways, in Ascribe, Starlight MDX, Elastic’s docs-builder, and Hugo, with a table that compares them construct by construct.
Tabs, steps, partials, and components
| Docusaurus or Starlight (MDX) | MkDocs | Hugo | In Ascribe |
|---|---|---|---|
<Tabs> with a <TabItem> for each tab; Starlight’s <Tabs syncKey>, <PackageManagerTabs> |
=== "npm" content tabs |
{{< tabs >}} with a {{< tab >}} for each |
A @variant group: an arm for each tab, @variant {pm=npm}:, and one @end. Tabs that are always the same choice, such as the package manager, are a dimension in ascribe.toml, so a build can keep one arm; a one-off set of tabs is labeled arms, a title line such as .Using Docker above each @variant: |
<Steps> around an ordered list |
A plain ordered list | A plain ordered list | @steps on the line above the list, with no wrapper to close |
import Partial from './_partial.mdx' and <Partial /> |
--8<-- "partial.md" |
{{% include "partial.md" %}} |
@include: _partial.md. A file whose name starts with _ is a fragment, not a page, so Docusaurus’s partials keep their names; rename the .mdx to .md |
:::tip[Title], :::tip Title, or Starlight’s <Aside type="tip" title="Title"> |
!!! tip "Title" |
> [!TIP], which the check reports, and --fix rewrites |
A title line, then the note: .Title on the line above @note {type=tip}. Without a title, @note {type=tip}: … alone |
<details> with a <summary> |
??? note "Title" |
{{< details >}} |
@details, with the summary as its title line |
| A value written into the page, such as a version | A {{ variable }} from mkdocs-macros |
{{% param "version" %}} |
A phrase, {version}, declared once in [phrases]. In a code block, the fence opts in with phrases=true |
<Badge>, or a label saying where a section applies |
@available under the heading, such as @available: self-managed 3.4, naming a target ascribe.toml declares |
||
Any other component the project wrote, such as <Video> |
A Markdown extension or a macro | A shortcode of the project’s own | A project widget: a directive declared in [widgets.<name>], such as @quill-video {id=intro}. The site writes it as a custom element with its name, for the site to define, and plain Markdown writes its fallback text |
Markdown that isn’t a directive stays as it’s written: an ordered list stays an ordered list. A heading’s id is @id on the line below it, as the table above rewrites it.
A copy of the docs for each version
Docusaurus keeps a copy of every page for each version in versioned_docs/, and mike publishes a copy of a whole MkDocs site for each. Ascribe keeps one copy, and builds a site for each version from it:
- Start from the newest copy, the one in
docs/, and leave the others out of the content root. - Where an older version’s page differs, mark what’s in some versions and not others with
@available:@available: self-managed 3.5under a heading that’s new in 3.5, oravailable:in a page’s frontmatter for a page that’s new. - List the versions a reader can be on in
[releases], aslive = ["3.4", "3.5"], and name it on the site’s build, asversions = "self-managed". Each live line gets its own output: the current line keeps the site’s addresses, so turning versions on moves none, and each older one is under its number, as/docs/3.4/. - For a version too old to rebuild, keep the site the old tool published, and list it under
archivedin[releases]with its address, so the live site lists it among the versions.
Publish a site for each version has each step, from listing the lines to moving them on when a version ships.
See also
ascribe init: what it writes, and its options.ascribe check: the check, its formats, and--fix.- Frontmatter: the keys every page can have.
- The
ascribe.tomlreference: types, and the fields they share.