How to add custom templates?

Created on 31 October 2022, about 2 years ago
Updated 26 September 2023, about 1 year ago

Problem/Motivation

How would I go about adding a custom paragraph template for the layout paragraph to use? I'm talking about coding HTML/CSS for my own two column or three column template to use. I watched a few videos on YouTube about how to use this module and it was mentioned that you can do this, but all that was said was to follow the instructions for adding templates for Layout Builder.

So I did that - I created a my_theme.libraries.yml file and provided a path to a custom template, but Drupal does not recognize the template. It still loads/uses the default two column template coming from Drupal core. Yes, I have cleared caches many times.

Has anyone successfully done this? Thanks.

πŸ’¬ Support request
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States maxq10

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • I have tried registering a layout according to megclaypool's suggestion, but Layout Paragraphs doesn't pick it up. My understanding is that the layouts that Layout Paragraphs uses are themselves paragraphs, and so somehow a special type of "layout" or "section" paragraph needs to be created for the Layout Paragraphs module to pick it up.

    Has anyone gotten this to work?

  • πŸ‡¦πŸ‡ΉAustria hudri Austria

    Layout paragraphs uses the same Layout discovery module as core's Layout Builder, so the documentation above is fully valid. If I remember correctly, you might need to create custom layouts.yml files in a custom module (not a custom theme) if you disabled frontend editing (because Layout discovery searches all modules and the active theme, which would be the admin theme).

  • I followed this - https://www.rapiddg.com/article/creating-custom-layouts-layout-paragraph...

    But there's some typos:

    The template file should be "layout--fourcol.html.twig" rather than "layout--fourcol.twig.html".

    Also "gh_display" in the full entry example for the layouts.yml should be "custom_layouts".

    More examples can be found in the "Layout Discovery" module within core.

Production build 0.71.5 2024