Skip to main content

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

simpblog-0.1.4.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

simpblog-0.1.4-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file simpblog-0.1.4.tar.gz.

File metadata

  • Download URL: simpblog-0.1.4.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

Hashes for simpblog-0.1.4.tar.gz
Algorithm Hash digest
SHA256 e8286fb97ea97030ee220efd258cb0457f54df55253f99a8538e572e01b68358
MD5 e93148c226187a063fdf764eefc1bdc3
BLAKE2b-256 83fd7b44b198695eb97f4533d2767cb95998d8babd0af78666091b26e53a4b6a

See more details on using hashes here.

File details

Details for the file simpblog-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: simpblog-0.1.4-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

Hashes for simpblog-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 08e94cd3bf1d6012c056be48c3d03750523e1419065fc3f6f92a7995acb04852
MD5 5cead16c00024b346cfabb5ae8a5357e
BLAKE2b-256 2e16f2ae78fa4b9590dad4f6ea2ac7e25b660340861af918d862a33496573b5f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page