bSSG – B Static Site Generator
bSSG is an extensible static site generator built on top of staticjinja. It provides support for templating (Jinja), internationalization (pyBabel), optimized thumbnail generation (Pillow), and build size minimization by excluding unreferenced files.
Features
- Templating support via Jinja
- Internationalization via pyBabel
- Responsive thumbnail generation using Pillow
- Output minimization by including only referenced static files
- Support for loading user-defined data (JSON) into templates
Architecture
A site that uses bSSG will have a source structure as:
input/
+- templates/
| +- <tree>
+- static/
| +- <static files to use in templates>
+- translations/
+- <language code>/
| +- LC_MESSAGES/
| +- messages.po
...
The generated site has the following structure:
build/
+- <language code>/
| +- <tree>
...
+- <static files used in templates>
+- thumb/
+- <generated thumbnails>
After generation, the site can be accessed via URLs of the form: {URL_PREFIX}/[{LANG_CODE}/]{SUFFIX}. Since the output is static, a web server must be configured so that URL_PREFIX maps to the build directory.
An optional STATIC_PREFIX can be used to group static files under a dedicated path instead of placing them at the root. Thumbnails are generated within the static directory, but an additional THUMB_PREFIX can be configured to isolate them in a separate subdirectory.
Usage
To create a website with bSSG:
- Generate the default configuration file:
bssg init. By default, this createsbssg.toml. A custom path can be specified with--cfg <file>. - Edit the configuration file as needed (see Configuration File).
- Write Jinja templates. Use
_('...')for translatable strings and the available filters (see Filters and Variables). - Handle translations (if applicable). NOTE: steps 4.1 and 4.2 are automated with
bssg get-translationsand step 4.4 is performed duringbssg build.- Extract the strings from the templates to a
.potfile. - Initialize or update
.pofiles (one for each language). - Edit the translations in
.pofiles. - Compile catalogs into
.mofiles (done automatically during build).
- Extract the strings from the templates to a
- Build the site:
bssg build. This compiles translations, generates thumbnails, and renders the site. - Copy static files:
bssg copy-static. Only files referenced at least once are copied.
Configuration File
The configuration file uses TOML format. By default, it is bssg.toml, but a different file can be specified with --cfg <file>.
It is divided into three sections: [site], [paths], and [data].
[site]
Defines URL structure and language behavior:
url_prefix: base URL of the site.languages: list of supported language codes.root_language(optional): language served at the root (<url_prefix>/...). Other languages are served under<url_prefix>/<lang_code>/.... Useful for single-language sites or when defining a primary language.static_prefix(optional): prefix for static assets (<url_prefix>/<static_prefix>/...).thumb_prefix(optional): prefix for generated thumbnails within the static directory.
[paths]
Defines input and output directories:
Input
templates: Jinja templates.locale: translation files (pyBabel).static: static assets (CSS, JS, images).
Output
cache: intermediate build data.build: output directory for the generated site.
[data]
Defines custom data sources with the format <var_name> = <path_to_json>. Each JSON file is loaded and exposed to templates under <var_name>.
Filters and Variables
The following variables and filters are made available in templates:
Variables
url_prefix: base URL from configuration.language: current language code.languages: list of configured languages.timestamp: value ofdatetime.datetime.now()at build start (constant across all templates and languages).generator: name and version of the generator (staticjinja).- Any
<var_name>defined in[data], containing the parsed JSON data.
Filters
absolute(url): returns<url_prefix>/<url>(does not include language prefix).static(path): registers a static file and returns its relative URL. Can be combined withabsolutefor full URLs.urltranslate(url, lang_code=None): adds a language prefix tourl. Defaults to the current language.thumb(path, width, aspect=None, suffix=".webp"): registers an image for thumbnail generation and returns its (static) URL.width: required (pixels).aspect: optional aspect ratio (defaults to original).suffix: output format (default:.webp).
thumbs(path, widths, fn=None, aspect=None, suffix=".webp"): generates multiple thumbnails for responsive images, returning a list formatted for the HTMLsrcsetattribute ("<url> <width>w").widths: list of widths.fn: optional function applied to each URL (e.g., theabsolutefilter).datefmt: alias forbabel.dates.format_date.
Release files for bssg 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| bssg-0.2.0.tar.gz | 15.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| bssg-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 30.4 kB
Release files / bssg-0.2.0.tar.gz
| Download URL | bssg-0.2.0.tar.gz |
|---|---|
| Size | 15.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
842cab1d986fe4436c647f562fb704dc479c426996a412bffe4ed175b5ee0d14
|
|
BLAKE2b-256 checksum How to use checksums |
a9893bdb5e675d84059fbfc440b02a1310008968e1fd0d4c5cba4ffed8c676e1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|
Release files / bssg-0.2.0-py3-none-any.whl
| Download URL | bssg-0.2.0-py3-none-any.whl |
|---|---|
| Size | 15.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
edd496bb8175f79276777964b5896afaeae59e1cabfbeee5e7c78a84928dcdcd
|
|
BLAKE2b-256 checksum How to use checksums |
20808549dd14c27189e29c05c4ca458550b911e3cc571f3405e8b2e90a02e9fc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|