Build your own Stacks Project in 10 minutes [0052]
- May 14, 2023
- April 25, 2024
- May 26, 2025
- Jon Sterling
The Stacks project is the most successful scientific hypertext project in history. Its goal is to lay the foundations for the theory of algebraic stacks; to facilitate its scalable and sustainable development, several important innovations have been introduced, with the tags system being the most striking.
Each tag refers to a unique item (section, lemma, theorem, etc.) in order for this project to be referenceable. These tags don’t change even if the item moves within the text. (Tags explained, The Stacks Project).
Many working scientists, students, and hobbyists have wished to create their own tag-based hypertext knowledge base, but the combination of tools historically required to make this happen are extremely daunting. Both the Stacks project and Kerodon use a cluster of software called Gerby, but bitrot has set in and it is no longer possible to build its dependencies on a modern environment without significant difficulty, raising questions of longevity.
Moreover, Gerby’s deployment involves running a database on a server (in spite of the fact that almost the entire functionality is static HTML), an architecture that is incompatible with the constraints of the everyday working scientist or student who knows at most how to upload static files to their university-provided public storage. The recent experience of the nLab’s pandemic-era hiatus and near death experience has demonstrated with some urgency the pracarity faced by any project relying heavily on volunteer system administrators.
Introducing Forester: a tool for scientific thought [0053]
- May 14, 2023
- Jon Sterling
After spending two years exploring the design of tools for scientific thought that meet the unique needs of real, scalable scientific writing in hypertext, I have created a tool called Forester which has the following benefits:
- Forester is tag-based like Gerby, and can therefore power large-scale generational projects like Stacks and Kerodon.
- Forester produces static content that can be uploaded to any web hosting service without needing to run or install any serverside software.
- Forester is easy to install on your own machine.
- To prevent bitrot, Forester is a single tool rather than a composition of several tools.
- Forester satisfies all the requirements of serious scientific writing, including sophisticated notational macros, typesetting of diagrams, etc.
Forester combines associative and hierarchical networks of evergreen notes (called “trees”) into hypertext sites called “forests”.
Definition Forests and trees of evergreen notes [tfmt-000R]
- March 4, 2023
- Jon Sterling
A forest of evergreen notes (or a forest for short) is loosely defined to be a collection of evergreen notes in which multiple hierarchical structures are allowed to emerge and evolve over time. Concretely, one note may contextualize several other notes via transclusion within its textual structure; in the context of a forest, we refer to an individual note as a tree. Of course, a tree can be viewed as a forest that has a root node.
Trees correspond roughly to what are referred to as “tags” in the Stacks Project.
In this article, I will show you how to set up your own forest using the Forester software. These instructions pertain to the Forester 5.0 version.
Preparing to run the Forester software [006R]
- August 13, 2023
- Jon Sterling
We will walk through the installation of the Forester software.
System requirements of Forester [006S]
- August 13, 2023
- Jon Sterling
Requirement A unix-based system [006T]
- August 13, 2023
- Jon Sterling
Requirement A working OCaml 5 installation [006U]
- August 13, 2023
- Jon Sterling
Requirement A working \LaTeX installation [006V]
- August 13, 2023
- Jon Sterling
If you intend to embed \LaTeX -rendered diagrams in your forest, you will need to have a working installation of \LaTeX installed, such as TeX Live. If all your mathematical expressions are supported by \KaTeX , this is not necessary.
Requirement The git distributed version control system [006Y]
- August 14, 2023
- Jon Sterling
It is best practice to maintain your forest inside of distributed version control. This serves not only as a way to prevent data loss (because you will be pushing frequently to a remote repository); it also allows you to easily roll back to an earlier version of your forest, or to create “branches” in which you prepare trees that are not yet ready to be integrated into the forest.
The recommended distributed version control system is git, which comes preinstalled on many unix-based systems and is easy to install otherwise. Git is not the most user-friendly piece of software, unfortunately, but it is ubiquitous. It is possible (but not recommended) to use Forester without version control, but note that the simplest way to initialize your own forest involves cloning a git repository.
Installing the Forester software [006W]
- August 13, 2023
- Jon Sterling
Once you have met the system requirements, installing Forester requires only a single shell command:
opam install forester
To verify that Forester is installed, please run forester --version in your shell.
Setting up your forest from the template [006X]
- August 14, 2023
- April 25, 2024
- June 17, 2024
- Jon Sterling
Now that you have installed the Forester software, it is time to set up your forest. Forester provides a simple command to initialise a fresh forest within a folder. We’ll call our folder forest, but you can call it anything you want.
mkdir forest cd forest
Now that we are inside our new directory, we can instruct Forester to initialise a forest.
forester init
This command initialises a git repository with the skeleton of a forest, which contains a configuration file named forest.toml; this file specifies the locations of your trees, assets, etc. There is also a git submodule bound to the theme/ directory (pointing to the base theme repository) that contains the stylesheets that web browsers will need in order to render your forest as HTML.
Tree addresses in a forest [0073]
- August 14, 2023
- June 17, 2024
- Jon Sterling
A tree in Forester is usually associated to an address of the form NNNN is a four-digit base-36 number. The purpose of the base-36 code is to uniquely identify a tree within your forest in such a way that you are not tempted to rename it, as you might be when titles or dates are embedded into filenames. A tree with address NNNN is stored in a file named NNNN.tree (unless it is emitted from inside another tree by means of the inline subtrees feature).
Note that the format of tree addresses is purely a matter of convention, and is not forced by the Forester tool. Users are free to use their own naming convention for tree addresses, and in some cases alternative (human-readable) formats may be desirable: this includes trees representing bibliographic references, as well as biographical trees. If you don’t like numerical tree addresses, nobody is forcing you to use them. The use of numerical addresses is suitable for projects like The Stacks Project, but it may not be appropriate for your own use-case.
Addresses in Forester are not hierarchical: all resources are rendered at the root of the forest, no matter where their source files are kept. This limitation is intentional, but we might revisit it in the future.
Building and viewing your forest for the first time [007D]
- August 15, 2023
- April 25, 2024
- Jon Sterling
To build your forest, you can run the following command of Forester’s executable in your shell:
forester build forest.toml
The --dev flag is optional, and when activated supplies metadata to the generated website to support an “edit button” on each tree; this flag is meant to be used when developing your forest locally, and should not be used when building the forest to be uploaded to your public web host.
Forester renders each tree to an XML document [007G]
- August 15, 2023
- Jon Sterling
Forester renders your forest to some XML files in the output/ directory; XML is, like HTML, a format for structured documents that can be displayed by web browsers. The forest template comes equipped with a built-in XSLT stylesheet (theme/default.xsl) which is used to instruct web browsers how to render your forest into a pleasing and readable format.
Serving and viewing your forest from a local web server [007I]
- August 15, 2023
- Jon Sterling
To view your forest while editing it, you must serve it from a local web server..To do this, first ensure that you have Python 3 correctly installed. Then run the following command from the root directory of your forest:
python3 -m http.server 1313 -d output
(You could replace 1313 with whatever port you prefer.) While this command is running, you will be able to access your forest by navigating to localhost:1313 in your preferred web browser.
In the future, Forester may be able to run its own local server to avoid the dependency on external tools like Python.
Creating your personal biographical tree [007K]
- August 15, 2023
- Jon Sterling
The first tree that you should create is a biographical tree to represent your own identity; ultimately you will link to this tree when you set the authors of other trees that you create later on. It is convenient to simply use a person’s full name to address a biographical tree. My own biographical tree is located at trees/people/jonmsterling.tree and contains the following source code:
\title{Jon Sterling}
\taxon{Person}
\meta{external}{https://www.jonmsterling.com/}
\meta{institution}{[[ucam]]}
\meta{orcid}{0000-0002-0585-5564}
\meta{position}{Associate Professor}
\p{Associate Professor in Logical Foundations and Formal Methods at University of Cambridge. Formerly a [Marie Skłodowska-Curie Postdoctoral Fellow](0061) hosted at Aarhus University by [Lars Birkedal](larsbirkedal), and before this a PhD student of [Robert Harper](robertharper).}Let’s break this code down to understand what it does.
- The declaration
\title{Jon Sterling}sets the title of the tree to my name. - The
\taxon{Person}declaration informs Forester that the tree is biographical. Not ever tree needs to have a taxon; common taxa includePerson,Theorem,Definition,Lemma, etc. You are free to use whatever you want, but some taxa are treated specially by Forester. - The subsequent
\metadeclarations attach additional information to the tree that can be used during rendering. These declarations are optional, and you are free to put whatever metadata you want. - Like in HTML, paragraphs must be wrapped in
\p{...}.
Do not hard-wrap your text, as this can have visible impact on how trees are rendered; it is recommended that you use a text editor with good support for soft-wrapping, like Visual Studio Code.
You can see that the concrete syntax of Forester’s trees looks superficially like a combination of \LaTeX and Markdown; Markdown-style links are used both for links to other trees and for links to external URLs. Forester’s concrete syntax is not fully documented, but it is less ambiguous than both \LaTeX and Markdown.
Creating a new tree using forester new [007H]
- August 15, 2023
- April 25, 2024
- Jon Sterling
Creating a new tree in your forest is as simple as adding a .tree file to the trees folder. Because it is hard to manually choose the next incremental tree address, Forester provides a command to do this automatically:
forester new forest.toml --dest=trees
In return, Forester should output the location of the new tree, e.g. trees/0002.tree. If we look at the contents of this new file, we will see that it is empty except for metadata assigning a date to the tree:
\date{2023-08-15}You may prefer to use randomised addresses over sequential addresses; this can be particularly useful if multiple people are contributing to a forest. In that case, pass the --random option to forester new.
Most trees should have a \date annotation; this date is meant to be the date of the tree’s creation; you can have more than one date, if you like to keep track of when a tree has been updated. You should proceed by adding further metadata: the title and the author; for the latter, you will use the address of your personal biographical tree.
\title{My first tree}
\author{jonmsterling}Tree titles should be given in lower case (except for proper names, etc.); these titles will be rendered by Forester in sentence case. A tree can have as many \author declarations as it has authors; these will be rendered in their order of appearance.
Now you can begin to populate the tree with its content, written in the Forester markup language. Think carefully about keeping each tree relatively independent and atomic.
Bottom-up hierarchy via transclusion [007L]
- August 15, 2023
- Jon Sterling
You may be used to writing \LaTeX documents, where you work from the top down: you create some section headings, put some text under those headings, make some deeper section headings, put more text, etc. Forests work in the opposite way, from the bottom up: you start by writing independent, atomic notes/trees and then only later start to (sparingly) assemble these into a hierarchy in order to reify the emerging structure.
Forester’s bottom-up approach to section hierarchy works via something called transclusion. The idea is that at any time, you can include (“transclude”) the full contents of another tree into the current tree as a subsection by adding the following code:
\transclude{address}This is kind of like \LaTeX ’s \input command, but much better behaved: for instance, section levels are computed on the fly depending on the position in the hierarchy. This entire tutorial is cobbled together by transcluding many smaller trees, each with their own independent existence. For example, the following two sections are transcluded from an entirely different part of my forest:
The best structure to impose is relatively flat [tfmt-0009]
- December 27, 2022
- Jon Sterling
It is easy to make the mistake of prematurely imposing a complex hierarchical structure on a network of notes, which leads to excessive refactoring. Hierarchy should be used sparingly, and its strength is for the large-scale organization of ideas. The best structure to impose on a network of many small related ideas is a relatively flat one. I believe that this is one of the mistakes made in the writing of the foundations of relative category theory, whose hierarchical nesting was too complex and quite beholden to my experience with pre-hypertext media.
One of the immediate impacts and strengths of Forester’s transclusion model is that a given tree has no canonical “geographic” location in the forest. One tree can appear as a child of many other trees, which allows the same content to be incorporated into different textual and intellectual narratives.
Hierarchical structure as non-unique narrative [tfmt-0006]
- December 26, 2022
- Jon Sterling
Multiple hierarchical structures can be imposed on the same associative network of nodes; a hierarchical structure amounts to a “narrative” that contextualizes a given subgraph of the network. One example could be the construction of lecture notes; another example could be a homework sheet; a further example could be a book chapter or scientific article. Although these may draw from the same body of definitions, theorems, examples, and exercises, these objects are contextualized within a different narrative, often toward fundamentally different ends.
As a result, any interface for navigating the neighbor-relation in hierarchically organized notes would need to take account of the multiplicity of parent nodes. Most hypertext tools assume that the position of a node in the hierarchy is unique, and therefore have a single “next/previous” navigation interface; we must investigate the design of interfaces that surface all parent/neighbor relations.
The Forester markup language [007N]
- August 16, 2023
- Jon Sterling
A tree in Forester is a single file written in a markup language designed specifically for scientific writing with bottom-up hierarchy via transclusion. A tree has two components: the frontmatter and the mainmatter.
Forester markup: frontmatter [007P]
- August 16, 2023
- Jon Sterling
The frontmatter of a Forester tree is a sequence of declarations that we summarize below.
| Declaration | Meaning |
|---|---|
\title{...}
|
sets the title of the tree; can contain mainmatter markup |
\author{name}
|
sets the author of the tree to be the biographical tree at address name
|
\date{YYYY-MM-DD}
|
sets the creation date of the tree; full ISO 8601 date-times are supported. |
\taxon{Taxon}
|
sets the taxon of the tree; example taxa include lemma, theorem, person, reference; the latter two taxa are treated specially by Forester for tracking biographical and bibliographical trees respectively |
\def\ident[x][y]{body}
|
defines and exports from the current tree a function named \ident with two arguments; subsequently, the expression \ident{u}{v} would expand to body with the values of u,v substituted for \x,\y
|
\import{address}
|
brings the functions exported by the tree address into scope
|
\export{address}
|
brings the functions exported by the tree address into scope, and exports them from the current tree
|
Forester markup: mainmatter [007O]
- August 16, 2023
- Jon Sterling
Below we summarize the concrete syntax of the mainmatter in a Forester tree.
| Function | Meaning |
|---|---|
\p{...}
|
creates a paragraph containing ...; unlike Markdown, it is mandatory to annotate paragraphs explicitly |
\em{...}
|
typesets the content in italics |
\strong{...}
|
typesets the content in boldface |
\ol{...}
|
creates an ordered list |
\ul{...}
|
creates an unordered list |
\li{...}
|
creates a list item |
#{...}
|
typesets the content in (inline) math mode using \KaTeX ; note that math mode is idempotent in Forester |
##{...}
|
typesets the content in (display) math mode using \KaTeX |
\transclude{address}
|
transcludes the tree at address address as a subsection |
[title](address)
|
formats the text title as a hyperlink to address address; if address is the address of a tree, the link will point to that tree, and otherwise it is treated as a URL
|
\let\ident[x][y]{body}
|
defines a local function named \ident with two arguments; subsequently, the expression \ident{u}{v} would expand to body with the values of u,v substituted for \x,\y.
|
\code{...}
|
typesets the content in monospace |
\tex{preamble}{body}
|
typesets the body externally using \LaTeX using preamble as preamble code (e.g. to set up tikz packages, etc.). It can be useful to wrap this in your own macro in order to insert your preamble code automatically. |
Example An complete worked example tree in Forester [007Q]
- August 16, 2023
- Jon Sterling
An example of a complete tree in the Forester markup language can be seen below.
\title{Creation of (co)limits}
\date{2023-02-11}
\taxon{Definition}
\author{jonmsterling}
\def\CCat{#{\mathcal{C}}}
\def\DCat{#{\mathcal{D}}}
\def\ICat{#{\mathcal{I}}}
\def\Mor[arg1][arg2][arg3]{#{{\arg2}\xrightarrow{\arg1}{\arg3}}}
\p{Let \Mor{U}{\CCat}{\DCat} be a functor and let \ICat be a category. The functor #{U} is said to \em{create (co)limits of #{\ICat}-figures} when for any diagram \Mor{C_\bullet}{\ICat}{\CCat} such that #{\ICat\xrightarrow{C_\bullet}\CCat\xrightarrow{F}\DCat} has a (co)limit, then #{C_\bullet} has a (co)limit that is both preserved and reflected by #{F}.}The code above results in the following tree:
Definition. Creation of (co)limits [001H]
- February 11, 2023
- Jon Sterling
Let {\mathcal {C}}\xrightarrow {U}{\mathcal {D}} be a functor and let \mathcal {I} be a category. The functor U is said to create (co)limits of \mathcal {I}-figures when for any diagram {\mathcal {I}}\xrightarrow {C_\bullet }{\mathcal {C}} such that \mathcal {I}\xrightarrow {C_\bullet }\mathcal {C}\xrightarrow {F}\mathcal {D} has a (co)limit, then C_\bullet has a (co)limit that is both preserved and reflected by F.
Deploying your forest to a web host [007R]
- August 16, 2023
- Jon Sterling
Now that you have created your forest and added a few trees of your own, it is time to upload it to your web host. Many users of Forester will have university-supplied static web hosting, and others may prefer to use GitHub pages; deploying a forest works the same way in either case.
- First, make sure your forest is built using the earlier instructions.
- Then take the entire contents of your
outputdirectory and upload them to your preferred web host.
Let a hundred forests bloom! [007S]
- August 16, 2023
- Jon Sterling
I am eager to see the new forests that people create using Forester. I am happy to offer personal assistance via the mailing list.
Many aspects of Forester are in flux and not fully documented; it will often be instructive to consult the source of existings forests, such as this one.
Have fun, and be sure to send me links to your forests when you have made them!