Configuration¶
config.py
¶
Your project’s configuration happens in a single config.py
file in the root directory (where the staticjinjaplus
CLI should be executed). You’ll find the available configuration values below.
Note
- All paths are relative to the root directory, unless otherwise stated.
- None of these configuration values are required, so is
config.py
. - Only uppercase variables are loaded by staticjinjaplus.
SERVE_PORT
¶
Type: int
Default: 8080
Listening port of the HTTP server started by staticjinjaplus serve
.
BASE_URL
¶
Type: str
Default: http://localhost:{SERVE_PORT}/
Protocol and domain name to use to generate meaningful absolute URLs. Set host part to [::1]
if you plan to use IPv6.
MINIFY_XML
¶
Type: bool
Default: False
Enable XML (including HTML, RSS and Atom) minification.
MINIFY_JSON
¶
Type: bool
Default: False
Enable JSON minification.
TEMPLATES_DIR
¶
Type: str
Default: templates
Directory containing the Jinja templates to be processed.
OUTPUT_DIR
¶
Type: str
Default: output
Directory where the rendered site will be saved.
STATIC_DIR
¶
Type: str
Default: static
Directory containing static files.
ASSETS_DIR
¶
Type: str
Default: assets
Directory containing assets, i.e. files that needs prior processing before being able to be used by the rendered site.
CONTEXTS
¶
Type: List[Tuple[str, Union[Dict[str, Any], Callable]]]
Default: []
staticjinja contexts to be used by templates.
WEBASSETS_BUNDLES
¶
Type: List[Tuple[str, Tuple[str,…], Dict[str, str]]
Default: []
webassets bundles to be registered. These are passed to
register()
. Sources are relative to
ASSETS_DIR
, destinations to OUTPUT_DIR
.
Note
rjsmin is already installed as dependency. It is internally used to minify JSON templates, and may be used in webassets bundles without any additional install step to minify Javascript files.
JINJA_GLOBALS
¶
Type: Dict[str, Any]
Default: {}
jinja globals to be made available in all templates.
JINJA_FILTERS
¶
Type: Dict[str, Callable]
Default: {}
jinja filters to be made available in all templates.
JINJA_EXTENSIONS
¶
Type: List[Union[str, jinja2.ext.Extension]]
Default: []
jinja extensions to load.
MARKDOWN_EXTENSIONS
¶
Type: Dict[str, Dict]
Default: {}
Markdown extensions to load and their respective configuration. Keys
are passed to extensions
; the entire dictionary is passed
to extension_configs
.
MARKDOWN_DEFAULT_PARTIAL
¶
Type: Optional[str]
Default: None
Default template partial to use when rendering Markdown files when the partial
metadata is not present.
USE_HTML_EXTENSION
¶
Type: bool
Default: True
If your site’s links are using URLs without .html
extension (URL rewrite), you must set this config value to False
.
This config value does not alter the behavior of absurl()
in any way.
Environment variables¶
Some configuration values may/must be overridden by environment variables of the same name when building your site
for production (staticjinjaplus publish
command), typically in a deployment environment. You’ll find the list below.
BASE_URL
¶
Required: Yes
Overrides BASE_URL
.
MINIFY_XML
¶
Required: No, but activation recommended
Overrides MINIFY_XML
. Must be set to any falsy
or truthy string
representation of boolean values allowed by marshmallow.
MINIFY_JSON
¶
Required: No, but activation recommended
Overrides MINIFY_JSON
. Must be set to any falsy
or truthy string
representation of boolean values allowed by marshmallow.