Theming Paragraphs in Drupal 8+
Template naming conventions
Paragraphs uses template naming suggestions like core Drupal modules. The default paragraphs template is provided in paragraphs/templates/paragraph.html.twig
.
The following suggestions are available, from most specific (used first) to least specific:
- paragraph--[type]--[view-mode].html.twig
(e.g.paragraph--image--default.html.twig
) - paragraph--[type].html.twig
(e.g.paragraph--image.html.twig
) - paragraph--[view-mode].html.twig
(e.g.paragraph--default.html.twig
) - paragraph.html.twig
After adding a template, you must rebuild the cache in order for Drupal to discover your new template.
It is possible to create custom template name suggestions using the hook_theme_suggestions_HOOK_alter() function.
Nesting paragraphs (building a grid)
Rather than using nested paragraph types for Paragraphs-centered grid solutions, a useful addition for this use case is the module Paragraphs Grid.
See also
- Twig Template Naming Conventions (for all core modules)
- Debugging Twig Templates
Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion