A Python-based static site generator that converts Markdown files to HTML, similar to Jekyll, Hugo, or Gatsby. This project was created as part of the boot.dev learning path.
- Converts Markdown files to static HTML pages
- Supports common Markdown syntax:
- Headers (h1-h6)
- Bold and italic text
- Code blocks with syntax highlighting
- Links and images
- Ordered and unordered lists
- Blockquotes
- Recursive directory processing
- Template-based page generation
static_site_generator/
├── src/ # Source code directory
│ ├── main.py # Main entry point
│ ├── htmlnode.py # HTML node classes
│ ├── textnode.py # Text node definitions
│ ├── markdown_to_html_node.py # Markdown conversion
│ ├── text_to_blocks.py # Text block parsing
│ ├── text_to_textnodes.py # Text node conversion
│ ├── text_to_html.py # HTML conversion
│ ├── extractors.py # Link/image extraction
│ ├── generate_page.py # Page generation
│ └── recursive_public_generator.py # Public dir management
├── public/ # Generated site directory
│ ├── index.html # Generated pages
│ ├── index.css # Site styling
│ └── images/ # Image assets
├── template.html # HTML template
├── main.sh # Run script with dev server
└── test.sh # Test runner script
- Clone the repository
git clone https://github.com/Armivio/SRG
cd static-site-generator- Ensure you have Python 3.12.3 installed
-
Add your Markdown content files to the
contentdirectory -
Use the template.html file for page structure:
{{ Title }}- Will be replaced with the page title{{ Content }}- Will be replaced with the page content
-
Run the generator and development server:
./main.shThis will:
- Generate the static site in the
publicdirectory - Start a development server at http://localhost:8888
Alternatively, just build without the server:
python3 src/main.pyRun the test suite:
./test.shor
python3 -m unittest discover -s srcThe site comes with a built-in dark theme styled similarly to GitHub's dark mode, featuring:
- Dark background with light text
- Syntax highlighting for code blocks
- Responsive design
- Styled blockquotes and links
- GitHub-like typography
The project uses an object-oriented approach with several key components:
HTMLNode: Base class for HTML elementsTextNode: Text content handler with support for various formats- Block parsers for Markdown structures
- Recursive directory handling
- Development server for local testing
This project is licensed under the MIT License - see the LICENSE file for details.
This project was developed as part of the boot.dev guided project "Build a Static Site Generator". The .css file, the long Markdown files, and the HTML template file were provided by boot.dev. The skeleton of the tests (and small bits of code where I could not solve the issues) were generated by ChatGPT o3-mini and o3-mini-high. However, heavy tinkering, modifications, and adaptations were required for the tests (and the other bits of code) to be useful and correct. Apart from that, all the code was written by me, during a ~3-day span.