Simple static site generator, for blogs and basic sites
Project description
simpblog
Simple static site generator that can be used to template the html/markdown for a simple blog or website.
why would I use this?
There's much better options, which you should probably use instead. This is just a simple python script but that may well be its appeal.
If all you need is basic html/markdown templating then simpblog maybe of use or could maybe be a stop gap solution before you settle on a more feature complete static site generator.
installation
# just script
wget https://raw.githubusercontent.com/alexk49/simpblog/refs/heads/main/simpblog.py
chmod +x simpblog.py
# or through pip
pip install simpblog
If you want the template site files, it will be best to clone the repo:
# script with template site:
git clone https://github.com/alexk49/simpblog.git
# set up script manually
python -m venv .venv
source .venv/bin/activate
pip install -e .
usage
./simpblog.py -h | --help
# pass path of site to build
./simpblog.py -s {site_dir} | --site-dir {site_dir}
# force full rebuild of site
./simpblog.py --force
# run build and start dev server
# if inotifywait is available will watch for changes and reload
./simpblog.py --dev
# specify the port for dev server:
./simpblog.py --dev --port
directory structure
Example files are included in the repo in pages, posts, static and templates for a quick start but these can just be used as a base or ignored completely!
Expected folders are:
pages posts templates static
Pages/posts will accept .md or .html files.
If you have a pages folder then you need a templates/page.html file, if you have a posts folder then you need a templates/post.html file.
You can just have a pages directory or just have a posts directory or have both.
templates directory
You must have a layout.html file, which will be used to base all over template files on.
posts/pages directories
In the post directory, you can add front matter to your files like:
---
title: Example post
slug: test
date: 2023-09-11
tags: test, example
---
Tags are special to posts and if you make a templates/tag.html then html pages will be made containing all the posts that match the tag.
In the pages directory, the only front matter needed is:
---
title: About
slug: about
---
If use .html files in the pages or post directory then the url slug for a html file will be read from the file name.
static directory
The static directory is for .css, .js and asset files. These are just copied across to the output folder.
homepage
The homepage can be made with its own template by placing index.html into the templates directory, or it can use the page.html template by placing index.html or index.md into the pages directory.
output directory
The built .html files will be generated in a directory called output. It will be built either in the directory that you can the script or in the directory you passed as site_dir.
dev server
Running the build with the dev server will use python's inbuilt http server to serve the output directory on the localhost. Port 8000 is used by default but this can be changed.
If inotifywait is installed then a rebuild will be triggered when changes are deteced in the pages, posts, static, and templates directories. Otherwise, the server will need to be manually restarted.
On debian/ubuntu, inotifywait can be installed with:
sudo apt install inotify-tools
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file simpblog-0.1.3.tar.gz.
File metadata
- Download URL: simpblog-0.1.3.tar.gz
- Upload date:
- Size: 9.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
30646410556ee28e662ca3f423562f4960251d9c7d00d2bb55e8108128d5cf1f
|
|
| MD5 |
a8be8d45d964acf8b8c38e613172cb49
|
|
| BLAKE2b-256 |
c3d081221c2154e4218011ca07cd4056e8c24f1341eebe88f90784bda860081a
|
File details
Details for the file simpblog-0.1.3-py3-none-any.whl.
File metadata
- Download URL: simpblog-0.1.3-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4410fadff3b1501cdb98d232f0284c9121adaf5de34a2bd337e21ad54f5c6f83
|
|
| MD5 |
41bda1e3281e1aeabae36c0e18f1392e
|
|
| BLAKE2b-256 |
19b2d462f6ea7fc9e22f064059a8133fceb9339fe30cf0314314da29701ee22b
|