Valid Definitions

Defining a Registered Shortcode (valid)

Defines the minimal properties a theme developer needs to define for a shortcode to integrate with Platen’s configuration, automatically and dynamically loading styles without requiring the end users to update their own site configuration or assets. and adding site-level control over the shortcode behaviors.

Platen, through the site configuration, keeps a registry of integrated shortcodes. This enables site authors and theme developers to discover, enable, disable, and configure shortcodes in a friendlier way than Hugo’s default, without preventing Hugo’s built-in behavior.

At a minimum, every registered shortcode must define the enabled setting. If the shortcode has specific styling needs, it must define the style setting with the name property set to the name of the style module in assets/styles/shortcodes, like tabs for the style module at assets/styles/shortcodes/_tabs.scss.

A registered shortcode’s style asset must be placed in the assets/styles/shortcodes folder.

In addition to these properties, any registered shortcode may define any other settings that make sense for it. Theme developers should use these settings to provide sensible defaults that are meant to be overridden.

For more information on developing a registered shortcode for Platen, see Defining a Registered Shortcode in the Theme Guide.

JSON Schema

Definition
{
  "$id": "https://platen.io/schemas/platen/site/shortcodes/valid/schema.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "description": "Defines the minimal properties for a Platen-aware shortcode\n\nhttps://platen.io/schemas/platen/site/shortcodes/valid/",
  "properties": {
    "Style": {
      "description": "Defines the settings for the shortcode's styling\n\nhttps://platen.io/schemas/platen/site/shortcodes/valid/#Style",
      "properties": {
        "name": {
          "description": "Specifies the name of the shortcode's style module\n\nhttps://platen.io/schemas/platen/site/shortcodes/valid/#name",
          "title": "Shortcode Style Module Name",
          "type": "string"
        }
      },
      "required": [
        "name"
      ],
      "title": "Shortcode Style Settings",
      "type": "object"
    },
    "enabled": {
      "default": true,
      "description": "Whether to enable the shortcode for the site\n\nhttps://platen.io/schemas/platen/site/shortcodes/valid/#enabled",
      "title": "Enable the Shortcode",
      "type": "boolean"
    }
  },
  "required": [
    "enabled"
  ],
  "title": "Defining a Registered Shortcode",
  "type": "object"
}

Required Properties

Enable the Shortcode (enabled)

Defines whether to enable the shortcode for the site. This value usually defaults to true. When this value is set to false, the configuration and styling for the shortcode is disabled and Platen raises an error when the shortcode is used.

Shortcode Style Settings (Style)

Defines the settings for the shortcode’s styling. This setting can be omitted if the shortcode has no specific styling needs (if it relies on existing or otherwise defined CSS or SCSS values to style its output).

If it needs its own SCSS, add the module to the assets/styles/shortcodes folder and set name to the SCSS module’s name, like foo for assets/styles/shortcodes/_foo.scss.

You can define any other key-value pairs here, which can then used in the shortcode’s style module when rendered as a template.

Required Properties

Shortcode Style Module Name (name)

Specifies the name of the shortcode’s style module in the assets/styles/shortcodes folder. Omit the leading _ and trailing .scss. For example, the name for the style module assets/styles/shortcodes/_foo.scss is foo.

Edit this page