Working with a specific static site generator? Customize CloudCannon's documentation to suit your SSG.
Great! We'll show you documentation relevant to . You can change this any time using the dropdown in the navigation bar.
CloudCannon supports embedding rich Snippets in Markdown content when using the CloudCannon Content Editor. Once configured, Snippets in your content will be presented as blocks in rich text views, with the ability to add them as Snippets via the toolbar:
To start configuring Snippets in your Markdown content, a Snippet configuration must be imported using the _snippets_imports key in your CloudCannon global configuration file.
Your SSG and theme may not enable the full set of Python Markdown extensions so we recommend using the include option to import only the Snippets you're using.
By default, CloudCannon will show the snippet toolbar action in the content editor if snippets are available.
If you have already customized which options are available via _editables in your CloudCannon config, you will need to include snippet: true for Snippets to be available. See the Editables options documentation for more details.
The Admonition snippet allows you to add standard Python Markdown admonitions to your content.
In addition, collapsible admonitions from the Details extension are supported
with the Collapsible Admonition snippet:
CloudCannon supports both fenced codeblocks with the Code Block snippet, and inline code highlighting from
the InlineHilite extension with the
Inline Code snippet:
Footnote support consists of two snippets, a footnote snippet and a footnote marker snippet.
The footnote snippets lets you define the content of a footnote, and then the marker snippet allows
you to reference a footnote in text.
The first part of reference-style links support is the reference snippet, which allows you to create a named reference
and set its URL.
example.md
copied
You can then use that reference in links in your page using the reference link snippet, or the reference template snippet
if your link title is the same as the reference name. If you're using reference links you must also include the regular link
snippet.
example.md
copied
You can also use references in images with the reference image snippet, or the reference template image snippet
if image text is the same as the reference name. If you're using reference images you must also include the regular image
snippet.
Some Python extensions don't work out of the box and require additional configuration. These are the Snippet extension and the Markdown in HTML extension.
By default any instance of these extensions will be escaped into either an HTML element or an Unknown Snippet, this allows an editor to move and delete these Snippets, but prevents editing of their arguments or content:
To enable editing and provide the custom snippet in the toolbar, your custom snippet must be configured using the _snippets object in your CloudCannon global config file. CloudCannon Snippets can be built from scratch to support nearly any syntax or SSG, but importing a Snippet configuration provides a set of snippet templates for common use cases in Python Markdown.
To help illustrate configuring custom Snippets, we will first cover a few examples. First, let's look a custom glossary snippet that includes a set of abbreviations for our site:
post.md
copied
The first thing we need to do is decide which Snippet template to use. Looking at the list of snippet templates
further down this page, we see that Python Markdown has two templates python_markdown_snippet and python_markdown_markdown_in_html.
Our glossary is using the Snippet extension so we should configure this snippet using the python_markdown_snippet template. A full example configuration for this Snippet thus might look like the following:
cloudcannon.config.yaml
copied
cloudcannon.config.json
copied
cloudcannon.config.cjs
copied
Each snippet definition lives under a top level key, glossary in this example. This is the unique name that CloudCannon uses to identify this snippet, but is otherwise unused in the snippet configuration itself.
We specify the template that this snippet should inherit from, and also specify that it is not an inline snippet, so it can only be used on a line on its own.
In definitions we need to specify some values that are required for the template we picked. For the python_markdown_snippet template, we need to specify:
The snippet_name — in this case we're configuring a snippet for the glossary.html file.
Finally, we can specify any other keys from the CloudCannon configuration cascade here. In this example, we configure the inputs for the keys that this snippet will generate. With that in place, we can now add and edit our glossary snippet anywhere on our site.
Next, let's quickly look at a snippet using Markdown in HTML:
post.md
copied
This time, we have an HTML figure with a class attribute of diagram and we want to be able to edit its contents in Markdown. This syntax matches the python_markdown_markdown_in_html template.
In CloudCannon, we could configure this snippet using the following global configuration:
cloudcannon.config.yaml
copied
cloudcannon.config.json
copied
cloudcannon.config.cjs
copied
In this example, we want to ensure that our block has a class of diagram but we don't want the class to be editable in CloudCannon. By using source_key with no editor_key we prevent
the class from being editable in CloudCannon, then the default and allowed_values settings ensure that all instances of this snippet have class diagram.
Whether this snippet can appear inline (within a sentence). Defaults to false, which will treat this snippet as a block-level element in the content editor.
The first step to configure your custom snippet is to identify which snippet template to use, as each snippet template requires a set of definitions keys to be configured. The following snippet templates are available:
Whether this argument is required for the shortcode. If false, shortcodes in your templates missing this argument will not match this snippet definition.
A list of values that this argument must be in order to match this snippet definition. Allows you to match different usages of the same shortcode to separate snippet definitions based on the value of an argument.