Rich Text inputs

Last modified: June 26th, 2024

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.

A Rich Text input lets your team members write markup content directly into your data files or front matter. Rich Text inputs have a text area for your content and a WYSIWYG toolbar for formatting your content.

You can configure the WYSIWYG toolbar for a Rich Text input the same way you configure the toolbar for the Content Editor. For more information, please read our documentation on configuring your Rich Text editors.

There are two types of Rich Text input:

  • HTML
  • Markdown

For each input, you can configure the type (HTML or Markdown), whether your team members are allowed to resize the text area, how CloudCannon saves an empty value, the initial height of the text area, and the upload paths or filenames for any assets uploaded through this input.

HTML#

The HTML Rich Text input stores all markup values as HTML. There are two ways to configure an HTML Rich Text input: using the type key or the CloudCannon key naming convention.

A screenshot of an HTML Rich Text input in the Data Editor.

Using the type key, you can define your input as an HTML Rich Text input with the “html” value. Define the type key under your input key name within _inputs. For more information, please read our documentation on configuring your inputs.

cloudcannon.config.yaml
copied
_inputs:
  content:
    type: html

All inputs are defined under the _inputs key, regardless of where they are in the configuration cascade.

The Rich Text input is called content.

The value of the type key determines the input type. This is an html Rich Text input.

cloudcannon.config.json
copied
{
  "_inputs": {
    "content": {
      "type": "html"
    }
  }
}

All inputs are defined under the _inputs key, regardless of where they are in the configuration cascade.

The Rich Text input is called content.

The value of the type key determines the input type. This is an html Rich Text input.

cloudcannon.config.toml
copied
[_inputs.content]
type = "html"

All inputs are defined under the _inputs key, regardless of where they are in the configuration cascade.

The Rich Text input is called content.

The value of the type key determines the input type. This is an html Rich Text input.

about.md
copied
---
content: |
  <p>This paragraph has <em>emphasis</em> and <strong>strength</strong>.</p>
  <ol>
    <li>Walk</li>
    <li>Run</li>
  </ol>
  <p>Linking to <a href="/">index</a>.</p>
---

Using the key naming convention, CloudCannon will interpret any input key named html or that ends in _html as an HTML Rich Text input.

about.md
copied
---
sidebar_html: |
  <p>This paragraph has <em>emphasis</em> and <strong>strength</strong>.</p>
  <ol>
    <li>Walk</li>
    <li>Run</li>
  </ol>
  <p>Linking to <a href="/">index</a>.</p>
---

Markdown#

The Markdown Rich Text input stores all markup values as Markdown. There are two ways to configure a Markdown Rich Text input: using the type key or the CloudCannon naming convention.

A screenshot of a Markdown Rich Text input in the Data Editor.

Using the type key, you can define your input as an HTML Rich Text input with the “markdown” value. Define the type key under your input key name within _inputs. For more information, please read our documentation on configuring your inputs.

cloudcannon.config.yaml
copied
_inputs:
  top_copy:
    type: markdown

All inputs are defined under the _inputs key, regardless of where they are in the configuration cascade.

The Rich Text input is called top_copy.

The value of the type key determines the input type. This is a markdown Rich Text input.

cloudcannon.config.json
copied
{
  "_inputs": {
    "top_copy": {
      "type": "markdown"
    }
  }
}

All inputs are defined under the _inputs key, regardless of where they are in the configuration cascade.

The Rich Text input is called top_copy.

The value of the type key determines the input type. This is a markdown Rich Text input.

cloudcannon.config.toml
copied
[_inputs.top_copy]
type = "markdown"

All inputs are defined under the _inputs key, regardless of where they are in the configuration cascade.

The Rich Text input is called top_copy.

The value of the type key determines the input type. This is a markdown Rich Text input.

about.md
copied
---
top_copy: |
  # Animals

  - Dogs
  - Cats

  ***Its raining cats and dogs.***
---

Using the key naming convention, CloudCannon will interpret any input key named markdown or that ends in _markdown as an Markdown Rich Text input.

about.md
copied
---
markdown: |
  # Animals

  - Dogs
  - Cats

  ***Its raining cats and dogs.***
---

You may need to convert the Markdown value into HTML to use it on your site:

specific doc

In your layout, use the markdownify function to render Markdown from front matter.

layout.html
copied
{% if page.markdown %}
  {{ page.markdown | markdownify }}
{% endif %}

specific doc

In your layout, use the markdownify function to render Markdown from front matter.

layout.html
copied
{{ with .Params.markdown }}
  {{ . | markdownify }}
{{ end }}

specific doc

Eleventy doesn't have a markdownify shortcode or filter by default, so using the value from this input depends on your specific implementation.

specific doc

SSGs vary in processing Markdown, so using the value from this input depends on your specific implementation.

Options#

You can configure Rich Text inputs using the options key under your input key, inside of _inputs.

cloudcannon.config.yaml
copied
_inputs:
  description:
    type: markdown
    options:
      allow_resize: false
      empty_type: 'null'
      initial_height: 200
      paths:
        dam_uploads: assets/images
        dam_uploads_filename: '[filename].[extension]'
cloudcannon.config.json
copied
{
  "_inputs": {
    "description": {
      "type": "markdown",
      "options": {
        "allow_resize": false,
        "empty_type": "null",
        "initial_height": 200,
        "paths": {
          "dam_uploads": "assets/images",
          "dam_uploads_filename": "[filename].[extension]"
        }
      }
    }
  }
}
cloudcannon.config.toml
copied
[_inputs.description]
type = "markdown"

  [_inputs.description.options]
  allow_resize = false
  empty_type = "null"
  initial_height = 200

    [_inputs.description.options.paths]
    dam_uploads = "assets/images"
    dam_uploads_filename = "[filename].[extension]"

Rich Text inputs have the following options available:

allow_resize - Boolean#

Shows or hides the resize handler to vertically resize the input. Defaults to true.

empty_type - string#

Set how an ‘empty’ value will be saved. Does not apply to existing empty values. Can be one of the following:

  • string - an empty value for this input will be stored as "".
  • null - an empty value for this input will be stored as a null value (default). This does not apply to TOML files.
initial_height - Integer#

Defines the initial height of this input in pixels (px). Defaults to 320. Supports values between 135 and 1200.

paths - Object#

Paths to common folders. Each path is relative to global site source. If unset, the paths default to those configured in the global configuration.

The available keys are:

  • dam_static for the location of statically copied assets for DAM files.
  • dam_uploads for the default location of newly uploaded DAM files.
  • dam_uploads_filename for the name of the uploaded file, when uploading DAM files.
  • static for the location of statically copied assets.
  • uploads for the default location of newly uploaded site files.
  • uploads_filename for the name of the uploaded file.

These paths control where new asset files are uploaded to. They also set the default path when choosing existing images, and linking to existing files.

You can use dynamic placeholders for uploads and dam_uploads. For more information, please read our documentation on adjusting file upload paths.

Valid values#

Rich Text inputs can have multiple valid values for empty, single line, and multiline content. Here are some examples of valid values for the key html. These work for both HTML and Markdown inputs.

Empty/null value:

  • html:

Any valid string (quoted or unquoted):

  • html: ""
  • html: ''
  • html: any string
  • html: "any string"
  • html: 'any string'

Any valid multiline string:

  • html: >
    multiline string
  • html: >-
    multiline string
  • html: >+
    multiline string
  • html: |
    multiline string
  • html: |-
    multiline string
  • html: |+
    multiline string

Any valid string:

  • html = ""
  • html = "any string"

Any valid escaped string:

  • html = ''
  • html = 'any string (literal)'

Any valid multiline string:

  • html = """
    multiline string"""
  • html = """\
    multiline string (trimmed) \
    """
  • html = '''
    literal multiline string'''

Null value:

  • "html": null

Any valid string:

  • "html": ""
  • "html": "any string"

Any valid multiline string:

  • "html": "multiline \n string"
Open in a new tab