a swirl

Structure of Eleventy Base Blog

Eleventy #

Eleventy transforms a directory of templates (of varying types) into HTML It deploys to Netlify.

The templates it supports are: Liquid, Nunjucks, Handlebars, HTML, Markdown, EJS,Haml, Pug, Javascript

The Eleventy website is https://11th.dev
Documentation is at https://www.11ty.dev/docs though these are of limited help if you do not know the template technology in the above list.

There is some information in README.md

The templates used in the base blog are Markdown (.md) and nunjucks (.njk).

eleventy.js has config information. This says

nunjucks is a templating language for javascript, written my mozzilla

liquid is a template language created by shopify. It is written in Ruby adn is used by many other web apps including jekyll (which is used by GitHub).

Eleventy base blog also makes use of json.

The folder _site #

_site is not included in the git changes. It gives a good starting point for working out what the code actually does. _site contains the following directories:

folderfilescomment
aboutindex.htmlthe about page
css index.csscss for blog pages
prism-base16-monokai.dark.css css for how code (```) should look
feed .htaccess.htaccess file
feed.jsonjson file of contents of whole site
feed.xmlxml file of contents of whole site
img.gitkeep.gitkeep is empty
page-listindex.html table of all pages with their links and titles
postsindex.html Archive page: list of blog posts with links
firstpost/index.html pages each containing a blog post
secondpost/index.html
thirdpost/index.html
fourthpost/index.html
tagsindex.html A page showing a list of tags in button format to click. Clicking takes you to the appropriate page below.
another-tag/index.html A list of blog posts with the tag in question.
number-2/index.html
second-tag/index.html

Then there are three single files in _site:

filecomment
404.htmlPage/Content not found error page
index.htmlhome page
sitemap.xmllist of urls of all pages in site with their last modified date in xml format.

The files that construct the final html site files #

The above html files are constructed by combining templates and content. The content of some of the files is generated automatically.

As above, we first look at the folders and then the individual files

Copied to _site as is
folderfilecomment
_datametadata.json Top level information about the site such as title and description.
_includespostslists.njkCode for creating a chronologial list of posts and lists of posts by tag
_includes/layoutsbase.njk HTML that goes in all pages: head, header, almost empty main, and (empty) footer. Uses metadata.json
home.njkTemplate for home page. Uses base.njk, template-class: tmpl-home.
post.njkTemplate for blog post pages. Uses base.njk, template-class: tmpl-post. Code for automatically providing links to next and previous posts.
aboutindex.mdcontent for about page (about/index.html) in markdown format
cssindex.csscss files are copied to css directory in _site as is
prism-base16-monokai.dark.css
feed htaccess.njkcode to create an .htaccess file
json.njkcode to create a json file of contents of whole site (feed.json)
feed.njkcode to create an xml file of contents of whole site (feed.xml)
img.gitkeep
node_modulesloads of directorieshave not explored
postsfirstpost.md Content for blog posts in markdown. One file for each post
secondpost.md
thirdpost.md
fourthpost.md
posts.jsonAdd the tag 'posts' to all content files in the directory.
filecomment
404.mdContent for error page when a page is not found. Uses home.njk. Becomes 404.html
archive.njkUses home.njk and postlists.njk. Creates a list of posts. The page shown under Archive. Becomes posts/index.html
index.njkHome page content. Uses home.njk. Generates a list of recent blog posts.
page-list.njkCreates a table of links and titles that includes every page in the site.
sitemap.xml.njkGenerates sitemap.xml
tags-list.njkCreates tags/index.html in _site. Creates a list of tags that link to pages that list the posts where those tags are included. Uses home.njk
tags.njkUses home.njk and postslist.njk. Generates a page which lists the posts for a given tag.

Other files #

filecomment
.editorconfigSome editor settigs to do with indenting, white space and EOL.
.eleventy.jsConfiguration file for eleventy
.eleventyignoreJust contains README.md. We don't want README to be part of the site.
package.jsonjson file to do with the package. Seems to alias npm commands.
README.mdInformation about how to set up eleventy and the base blog