This is a static site generator, written in Python, that creates a static site from a collection of markdown files.
This project uses Nix flakes. Nix must be installed with the experimental-features nix-command and flakes enabled.
To build and serve the static site on 0.0.0.0:8888 (or whatever your loopback address is, on port 8888):
nix runTo enter a development shell with all the necessary dependencies available:
nix developWhilst developing using nix develop, there are several commands available:
build- builds the static sitetests- executes unit tests for the projectserve- serves the site on port8888format check- checks code formatting using blackformat fix- fixes code formatting using black
- Content you wish to serve is placed in the
contentdirectory. Each file in this directory will be a markdown file that will be converted to HTML. Content can be organized into subdirectories. - Static content (images, CSS, etc.) is placed in the
staticdirectory. This content will be copied to the output directory as-is, using the existing directory structure. template.htmlis the template that will be used to render the content. Site generation will replace the{{ Content }}placeholder with the content of the markdown file, and the{{ Title }}placeholder with the Heading 1 from the file. Note: A missing Heading 1 will cause the page generation to fail.- The
publicdirectory is where the generated site will be placed. This directory is removed (if existing) and recreated upon each site generation. - The
srcdirectory contains the source code for the static site generator, and is structured as follows:main.pyis the entry point. This file kicks off the site generation process.markdown_block_functions.pycontains functions for processing markdown block elements.markdown_conversion_functions.pycontains functions for converting markdown to HTML.markdown_inline_functions.pycontains functions for processing markdown inline elements.nodes_htmlnode.pycontains theHTMLNodeclass and child classes, which represent HTML elements.nodes_textnode.pycontains theTextNodeclass, which represents a text node.site_generation_functions.pycontains functions for generating the site.
- The
testsdirectory contains unit tests for the project. Each test file corresponds to a source file.
This project was built as part of the Static Site Generator Course from Boot.Dev