markdown_template

The `markdown_template` directive specifies a template file to be used for rendering Markdown content in NGINX.

Syntaxmarkdown_template filename;
Defaultnone
Contextlocation
Arguments1

Description

The markdown_template directive is utilized within NGINX's Markdown-to-HTML module to define a custom HTML template file for processing Markdown content. When Markdown content is requested, the module fetches the Markdown file, converts it to an HTML representation using a Markdown parser, and then wraps it with the specified HTML template. This enables users to create a consistent look and feel across their Markdown-rendered pages by allowing custom head and footer elements to be injected seamlessly.

To use the markdown_template directive, you need to specify the path to an HTML template file as its argument. The directive must be defined within a location block of the NGINX configuration file. The module will attempt to read the specified template file at the time a request is processed. If successful, the content of the template is combined with the converted Markdown to form the final HTML response. Error handling is also present to log issues if the template file cannot be read or accessed properly.

As you craft configurations with the markdown_template directive, ensure that your web server has the necessary permissions to access the template file. The template can include standard HTML content, such as headers or footers, and can use variable placeholders to incorporate dynamic content from the Markdown being processed.

Config Example

location /markdown {
    markdown_template /path/to/template.html;
}

Ensure the specified template file path is correct and accessible by the NGINX process.

If the template file is incorrectly formatted or unreadable, errors may occur during request processing.

Make sure that the Markdown content does not introduce syntax issues with the HTML template you provide.

← Back to all directives