Pages
Pages is a command line static site generator.
Piglet templates are used by default, but Jinja2, Chameleon, Genshi or Kajiki can all be used supported, and content can be read from reStructuredText, markdown or JSON data files.
Quick start
To get up and running with the default configuration of Piglet + reStructuredText:
pip install pages pages --template layout.html --output build/ src/
For markdown, or to use another templating system, install the relevant extras hook, eg:
pip install pages[markdown,jinja2]
Examples
Select individual files to render:
pages --template layout.html -p1 --output=build/ src/index.md src/page1.md
Select a different template for a file:
pages --template layout.html -p1 --output=build/ src/ src/stats.json:report.html
Read the list of files to render from stdin:
find src/ -type f -name \*md | pages --template layout.html -p1 --output=build/
Select a different templating system:
pages --render-with jinja2 --template layout.html --output=build/ src/
Load additional data into the template context:
# Inline JSON
pages --template layout.html --context '{"foo": "bar"}' src/
# a JSON file
pages --template layout.html --context data.json src/
# JSON loaded from a remote API
pages --template layout.html --context <(curl -s 'wttr.in/?format=j1') src/
# A python module
pages --template layout.html --context myproject.somemodule:avariable src/
# A python script
pages --template layout.html --context somevars.py src/
Path stripping
If you supply a directory to pages, it will render all the files inside that directory, stripping off the directory name. For example given a file at src/index.rst, this:
pages -t layout.html -o build/ src/
will produce this:
build/index.html
It will not strip the prefix of individually named files, so this:
pages -t layout.html -o build/ src/index.rst
will produce this:
build/src/index.html
Use -p <n>/--strip <n> to tell pages to remove one or more levels of path prefix. -p 1 will strip off one level of prefix, higher values will strip off more. -p 0 will leave the path unmodified.
Note that -p/--strip is only used for sources listed by full path names.
Rendering markdown
Markdown sources are processed using Python-Markdown with the “extra” and “meta” extensions loaded.
The template will be called with the following context variables:
{
"html": ..., # Content rendered as HTML
"meta": ..., # Parsed metadata
}
Rendering reStructuredText
reStructuredText sources make the following context variables available to the template:
{
"title": ... # Document title
"meta": ... # Key-value pairs from top level field lists
"html": ... # Rendered html body (incl. the title heading)
"html_without_title": ... # As above, but without the title heading
"parts": ... # Parts dict as returned by the docutils writer
}
Metadata
Release files for pages 0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pages-0.3.tar.gz | 13.8 kB | Without provenance | Details for pages-0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pages-0.3-py3-none-any.whl | Python 3 | none | any | Details for pages-0.3-py3-none-any.whl |
Total release size: 29.5 kB
Release files / pages-0.3.tar.gz
| Download URL | pages-0.3.tar.gz |
|---|---|
| Size | 13.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7c7c452c8a6dd67f3645beb54f94891ae053921ca8d4fb6b57b957375a1de1c9
|
|
BLAKE2b-256 checksum How to use checksums |
fcf2c66db080b87ec42ebdcfedfaa4a2402bd68c99a5dbf660039493c0083dc6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.8.13
|
Release files / pages-0.3-py3-none-any.whl
| Download URL | pages-0.3-py3-none-any.whl |
|---|---|
| Size | 15.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
df7ddd10f55765c28dd4a5112d847a8863f8a0e58da86642577388793c9c6bbb
|
|
BLAKE2b-256 checksum How to use checksums |
4ab9f285e5bc7aa51276dac5e18e5f3fdfb832368cc5980f1d3cd1ff784d46bb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.8.13
|
Security for pages 0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.