___
/ | ____ ____ ____ _
/ /| | / __ \/ __ \/ __ `/
/ ___ |/ / / / / / / /_/ /
/_/ |_/_/ /_/_/ /_/\__,_/
A static site generator in go
Inspired by Hugo and Saaru, this static site generator aims to take performance to the next level with parallel rendering, live reload and so much more, all in Go.
Pronounced: /ÉnĖÉ/
which means rice in Kannada š
This Project is a part of the ACM PESU-ECC's yearly AIEP program, and is maintained by Adhesh Athrey, Nathan Paul, Anirudh Sudhir, and Aditya Hegde
The ssg currently requires the following directory structure
/anna
āāā /cmd
āāā /pkg
āĀ Ā āāā /engine
āĀ Ā āāā /helpers
āĀ Ā āāā /parser
āāā /site
ā Ā Ā āāā /content
ā āĀ Ā āĀ Ā āāā /posts
ā ā ā āāā sample.md
ā Ā Ā āĀ Ā āāā index.md
ā āāā /layout
ā āĀ Ā āāā config.yml (This file is necessary and cannot be omitted)
ā āĀ Ā āāā page.html (This file is necessary and cannot be omitted)
ā āĀ Ā āāā posts.html (This file is necessary to create a 'Posts' section)
ā āĀ Ā āāāā /partials
ā āĀ Ā Ā Ā āāā partials for page
ā āāā /static
ā āĀ āāā /fonts
ā āĀ āāā /images
ā āĀ āāā plane.jpg
ā āĀ āāā /scripts
ā āĀ āāā style.css
ā Ā Ā ā /rendered (This directory is created by the ssg)
āāā /test (Stores mock data required to test the SSG)
āāā /engine
āĀ Ā āāā /merged_data_test
āĀ Ā āāā /render_engine_generated
āĀ Ā āāā /render_page
āĀ Ā āāā /render_tags
āĀ Ā āāā /render_user_defined
āāā /parser
āāā /input
āāā /layout
āāā /parse_md
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 as the folder is recursively rendered.
Static assets such as images and fonts are stored in static/
Scripts are stored in the scripts/
dir in static/
The layout of the site is configured using html files in layout/
config.yml
file stores the configuration of the site and includes details such as the baseURLpage.html
file defines the layout of a basic page of the siteposts.html
file defines the layout of a page displaying all the posts of the sitepartials/
folderEach layout file(except posts.html
and tags.html
) can access any data from the entire ssg
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 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
{{$PageData.Frontmatter.Title}}
: Returns the value of the title tag{{$PageData.Body}}
: Returns the markdown body rendered to HTML{{$PageData.Layout.[Tagname]}}
: Returns the particular configuration detail of the page
{{$PageData.Layout.Navbar}}
: Returns a string slice with the names of all the navbar elementsIn addition to page data, the following fields can be accessed:
{{.DeepDataMerge.Tags}}
- A map that stores the template 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 from config.yml
{{.DeepDataMerge.Posts}}
- Stores a slice of templates of all posts{{.DeepDataMerge.JSONIndex}}
- Stores the JSON index generated for a particular site
(primarily used for search and graphing of tags)Images: To add images, add it to the 'static/' folder or a subdirectory under it. Use /static/[imagename.format]
as the image link format in the markdown files.
CSS: CSS can be added in the following ways:
In an external file in the static/
directory and linked to the layout files
To link the stylesheet, use the baseURL
along with the relative path
Example: <link rel="stylesheet" href="{{.Layout.BaseURL}}static/style.css">
Placed inside <style></style>
tags in the <head></head>
of the layout files
Inline with the html elements
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 type 'post' for postsdescription
: 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 pageauthors
: Stores (multiple) author/s of a particular page(The above tags are Frontmatter tags)
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(The above tags are Layout tags)
config.yml
navbar:
- about
- posts
baseURL: http://localhost:8000/
# 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
curl -L https://github.com/acmpesuecc/anna/releases/download/<tag>/<release>.tar.gz > anna.tar.gz
tar -xvf anna.tar.gz
./anna
brew tap anna-ssg/anna
brew install anna
If you don't have a site dir with the pre-requisite layout template; anna proceeds to fetch the default site dir from our GitHub repository
Usage:
anna [flags]
Flags:
-a, --addr string ip address to serve rendered content to (default "8000")
-d, --draft renders draft posts
-h, --help help for anna
-l, --layout validates html layouts
-p, --prof enable profiling
-s, --serve serve the rendered content
-v, --version prints current version number
-w, --webconsole wizard to setup anna
Detailed documentation for our SSG can be found: here
If you have git installed, clone our repository and build against the latest commit
git clone github.com/acmpesuecc/anna; cd anna
go build