File organization
Inside a given working directory, wmk assumes the following subdirectories for
content and output. They will be created if they do not exist:
-
htdocs: The output directory. Rendered, processed or copied content is placed here, andwmk servewill serve files from this directory. -
templates: Mako templates (or Jinja2 templates ifjinja2_templatesis set to true inwmk_config.yaml). Templates with the extension.mhtml(.htmlif Jinja2 templates are being used) are rendered directly intohtdocsas.htmlfiles (or another extension if the filename ends with.$ext\.mhtml/$ext\.html, where$extis a string consisting of 2-4 alphanumeric characters), unless their filename starts with a dot or underscore or contains the stringbase, or if they are inside a subdirectory namedbase. For details on context variables received by such stand-alone templates, see Context variables. -
content: typically markdown (*.md) and/or HTML (*.html*) content with YAML metadata, although other formats are also supported. For a full list, see Input formats above. - Markdown (or other supported content) will be converted into HTML and then
"wrapped" in a layout using the
templatespecified in the metadata ormd_base.mhtmlby default. - HTML files inside
contentare assumed to be fragments rather than complete documents. Accordingly, they will be wrapped in a layout just like the converted markdown. In general, such content is treated just like markdown files except that the markdown-to-html conversion step is skipped. For instance, shortcodes can be used normally, although they may not work as expected if they return markdown rather than HTML. (Complete HTML documents are best placed instaticrather thancontent). - The YAML metadata may be (a) at the top of the md/html document itself,
inside a frontmatter block delimited by
---; (b) in a separate file with the same filename as the content file, but with an extra.yamlextension added; or (c) it may be inindex.yamlfiles which are inherited by subdirectories and the files contained in them. For details, see Site, page and nav variables. - The target filename will be
index.htmlin a directory corresponding to the basename of the source file – unlesspretty_pathin the metadata isfalseor the name of the file itself isindex.mdorindex.html(in which case the relative path is remains the same, except that the extension is of course changed to.htmlif the source is a markdown file). - The processed content will be passed to the template as a string in the
context variable
CONTENT, along with other metadata. - A YAML datasource can be specified in the metadata block as
LOAD; the data in this file will be added to the context. For further details on the context variables, see Context variables. -
Files that have other extensions than
.md,.htmlor.yamlwill be copied directly over to the (appropriate subdirectory of the)htdocsdirectory. This is so as to enable "bundling", i.e. keeping images and "attachments" together with related markdown files. -
data: YAML files for additional metadata. May be referenced in frontmatter data or used by templates. Other data files (CSV, SQLite, etc.) should typically also be placed here. -
py: Directory for Python files. This directory is automatically added to the front ofsys.pathbefore Mako or Jinja2 is initialized, meaning that templates can import modules placed here. Implicit imports (for Mako only) are possible by settingmako_importsin the config file (see the "Configuration file" section). There are also two special files that may be placed here:wmk_autolaod.pyin your project, andwmk_theme_autoload.pyin the theme'spy/directory. If one or both of these is present, wmk imports a dict namedautoloadfrom them. This means that you can assignPREPROCESSandPOSTPROCESSpage actions by name (i.e. keys in theautoloaddict) rather than as function references, which in turn makes it possible to specify them in the frontmatter directly rather than having to do it via a shortcode. (For more onPRE-andPOSTPROCESS, see the "Site, page and nav variables" section). -
assets: Assets for an asset pipeline. The only default handling of assets involves compiling SCSS/Sass files in the subdirectoryscss. They will be compiled to CSS which is placed in the target directoryhtdocs/css. Other assets handling can be configured via settings in the configuration file, e.g.assets_commandsandassets_fingerprinting. This will be described in more detail in Site, page and nav variables. Also take note of thefingerprinttemplate filter, described in Template filters. -
static: Static files. Everything in here will be rsynced directly over tohtdocs.