Table of Contents #
- Directory structure
- Description of the directory structure
- Building layouts
- Frontmatter
- Body
- Static assets
- Site configuration
- Notes
Directory structure #
The ssg currently requires the following directory structure
site
├── content
│ ├── docs.md
│ ├── index.md*
│ ├── notes
│ │ └── anna
│ │ └── zettelkasten.md
│ ├── posts
│ │ ├── bench.md
│ │ ├── building-anna
│ │ │ ├── images
│ │ │ │ ├── bench.png
│ │ │ │ └── wizard.gif
│ │ │ ├── index.md
│ │ └── weekly-progress
│ │ ├── week-1.md
│ │ ├── week-2.md
│ │ └── week-3.md
├── layout
│ ├── config.yml*
│ ├── note.html*
│ ├── notes.html*
│ ├── page.html*
│ ├── partials
│ │ ├── head.html
│ ├── posts.html*
│ ├── robots.txt*
│ ├── tag-subpage.html*
│ └── tags.html*
├── public
└── static
├── fonts
│ ├── VictorMono
│ │ └── victormono_italics.ttf
├── scripts
│ └── light.js
├── style.css
├── styles
└── tokyo-dark.css
Files marked * are required and cannot be omitted
Anna must be run from the parent of the site/ dir
Description of the directory structure #
-
All of the site data, including the content, configuration and static files, are stores in site/. The rendered/ directory generated by ssg is also stored in site/.
-
The markdown content for the site is stored in
content/
. It can contain subdirectories along with images as the folder is recursively rendered.- The contents of this dir is rendered to the root of
rendered/
- The
notes/
folder holds markdown notes which are rendered by a different process and include various note-specific features
- The contents of this dir is rendered to the root of
-
Static assets such as fonts are stored in
static/
-
Scripts are stored in the
scripts/
dir instatic/
-
The layout of the site is configured using html files in
layout/
- The
config.yml
file stores the configuration of the site and includes details such as the baseURL - The
page.html
,posts.html
and other necessary layouts define the structure of the various pages of the site such as posts.html, tags.html and regular pages - The layout files can be composed of smaller html files which are stored in the
partials/
folder
- The
-
Contents in
public/
are rendered to the root ofrendered/
Building layouts #
Each layout file can access any data from the entire ssg
The posts.html
layout can access the following data
{{.DeepDataMerge}}
{{.PageURL}}
{{.TemplateData}}
The tags.html
page can access the following data
{{.DeepDataMerge}}
{{.PageURL}}
{{.TemplateData}}
{{.TagNames}}
The remaining pages can access the following data
{{.DeepDataMerge}}
{{.PageURL}}
PageURL #
The {{.PageURL}}
is of the form index.html
, posts/tech/go.html
and so on.
Elements stored in DeepDataMerge
#
{{.DeepDataMerge.Templates}}
- A map that stores the template data of all the pages of the site for the particular url(the URL is the PageURL for the speicified page){{.DeepDataMerge.Tags}}
- A map that stores the template data of the tag sub-pages for a particular tag url{{.DeepDataMerge.TagsMap}}
- A map that stores a slice of templates of all posts for a particular tag url{{.DeepDataMerge.LayoutConfig}}
- Stores the layout parsed fromconfig.yml
{{.DeepDataMerge.Posts}}
- Stores a slice of the template data of all posts{{.DeepDataMerge.Notes}}
- Similar toPosts
but for all the notes part of the site{{.DeepDataMerge.LinkStore}}
- Stores a map which contains a slice of pointers to the linked notes.{{.DeepDataMerge.JSONIndex}}
- Stores the JSON index generated for a particular site (primarily used for search and graphing of tags)
Accessing specific page data #
The URL for the current page can be accessed using {{.PageURL}}
To access the data for a particular page, use Go templating syntax:
{{$PageData := index .DeepDataMerge.Templates .PageURL}}
{{$PageData.CompleteURL}}
To access the page data for posts.html
, tags.html
and their respective partials, set
{{$PageData := .TemplateData}}
All of the following page data fields can be accessed in the above manner:
{{$PageData.CompleteURL}}
: Returns the complete url of the given page{{$PageData.Date}}
: Returns the last modified date of the current file{{$PageData.Frontmatter.[Tagname]}}
: Returns the value of the frontmatter tag- Example:
{{$PageData.Frontmatter.Title}}
: Returns the value of the title tag
- Example:
{{$PageData.Body}}
: Returns the markdown body rendered to HTML
Frontmatter #
Metadata such as the title of the page can be added as frontmatter to the markdown files in the YAML format. This metadata can be accessed from the layout files with the appropriate syntax.
Currently, the following frontmatter tags are supported:
title
: The title of the current pagedate
: The date of the current pagedraft
: When set to 'true', the current page is not rendered unless the '-d' flag is usedscripts
: Stores the page-level scripts to be addedtype
: Sets the type of the page. Use typepage
for regular pages,post
for posts ¬e
for notes
Important #
anna will not render a page unless it contains the
type
field in the frontmatter
description
: Stores the description of the current post previewed in posts.htmlpreviewimage
: Stores the preview image of the current pagetags
: Stores the tags of the particular pagetoc
: When set to 'true', a table of contents is rendered for the current page
Important #
anna automatically renders a table of contents for every file of
type: post
authors
: Stores (multiple) author/s of a particular pagehead
: Users need to manually specify head of the zettel in the frontmatter. Only head notes will be a part ofnotes.html
Body #
Anna uses Goldmark to render markdown files, which is CommonMark compliant
A few useful goldmark extensions have been included:
- anchor
- adds support for anchors next to all headers
- figure
- parse markdown paragraphs that start with an image into HTML
<figure>
elements
- parse markdown paragraphs that start with an image into HTML
- mermaid
- adds support for Mermaid diagrams
- toc
- adds support for rendering a table-of-contents
Static assets #
Images #
Images can be added to the content/
dir, public/
dir or the static/
dir.
The contents of the static/
and public/
directories and the non-markdown files present in the content/
dir are copied to rendered/
The images can be referenced in the markdown files via their relative or absolute paths
CSS #
CSS can be added in the following ways:
-
In an external file in the
static/
directory and linked to the layout filesExample:
<link rel="stylesheet" href="/static/style.css">
-
Placed inside
<style></style>
tags in the<head></head>
of the layout files -
Inline with the html elements
Site configuration #
The config.yml file stores additional information regarding the layout of the site It contains the following fields:
navbar
: Stores the links to be added to the navbar (same name as the markdown files)baseURL
: Stores the base URL of the sitesiteTitle
: Stores the name of the sitesiteScripts
: Stores the javascript files to be included with every pageauthor
: Stores the author of the site
Sample config.yml
#
navbar:
- about
- posts
- tags
# make sure no trailing slash com/
baseURL: https://example.com
# Replace this with the actual canonical-url of your site
# baseURL tells search-engines (SEO), web-crawlers (robots.txt) so people can discover your site on the internet.
# It's also embeded in your sitemap / atom feed and can be used to change metadata about your site.
siteTitle: anna
siteScripts:
author: Anna
Notes #
Anna provides users with functionality of maintaining notes and sharing them. Notes opens another set of functionality for anna. Users can create under the site/notes
directory. Besides similar use cases as a post, notes can be short snippets of information, code or even some kind of list that the users want. It supports some important aspects of zettelkasten where users can link notes to each other, and organise similar posts in a zettel.
We aren't trying to re-invent the process of making an editor that helps users maintain these zettels as there are already some fantastic applications, namely Obsidian, Ginko Writer and Evergreen Notes. Our application as a rather needs to provide a generator to stitch these notes together to make it accessible on the site.
Notes directory structure #
/notes
├── /zettel A
└── /zettel B
├── note A
├── note B
└── note C
Linking Notes #
Notes can be linked by using callouts in markdown files such as [[]]
. The parser will validate these links during the runtime. It checks whether there are existing valid notes with a title matching the content of the callout. If not an error is thrown and you wont be able to compile the site.
For example. If you have a note with the title Note A
and you would like to reference it else where in another note (could even be part of another zettel). Then [[Note A]]
would be the appropriate callout to use it.