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://github.com/alexk49/simpblog/blob/main/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.1.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.1-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: simpblog-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 9ed138387ed22b1f8feea9cecaa5028a6b2ad42aab8df0e60f332ee22761ad26
MD5 23a9a3ec90382ce6ca93963b3889a1aa
BLAKE2b-256 22dd816a38633843d131ffbd57c293be8f1b14022bb1d3b4ebaef5d4725c4c1a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: simpblog-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4272398d1983f7c1cecd77ba01c47152e315fe245e91c83dbc975fe62c82cad4
MD5 9de7679d0dde120f6af68de32a2407b3
BLAKE2b-256 cc8a3a6b5ad7b79f030ac6efcc7ac372203231011b9237cc9e7959546932ada7

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