Configuration
You can customise Shortcodes’ settings using a PHP configuration file. The file is optional, but you need a mapping when a shortcode should render one of your Twig templates.
Create shortcodes.php in your Craft project's /config directory. This example maps a notice shortcode to a template:
<?php
return [
'map' => [
'notice' => '_shortcodes/notice.twig',
],
];Create templates/_shortcodes/notice.twig with the content you want to display:
<p class="notice">Our office is closed on public holidays.</p>Add [notice] to a text field, then apply the shortcodes filter when rendering that field. See Usage for passing context and handling rich-text paragraphs.
Configuration Options
Type: array · Default: []
Maps shortcode names to handlers. The opening example uses a Twig template path relative to your project's templates directory. Add further names to the same map for other reusable content.
Type: int · Default: 1048576
Sets the maximum number of bytes that Shortcodes will parse in one value. Oversized rich-text values are returned without expanding shortcodes, while oversized plain-text values remain HTML-encoded. This protects page renders from excessive parser work. Set this to 0 only when another trusted layer enforces an equivalent limit.