Theming a Block template
In the case of our Categories block, we can begin by navigating to the core/modules/block/templates
folder and following these remaining steps:
Copy
block.html.twig
and place it into ourtheme/octo/templates
folder.Rename
block.html.twig
toblock--views-block--categories-block-1.html.twig
based on the template's suggestions.Next, we will need to replace the current markup with the following new markup to convert the default
<h2>
to<h4>
:New markup
{% set classes = ['block'] %} <div{{ attributes.addClass(classes) }}> {{ title_prefix }} {% if label %} <h4{{ title_attributes }}>{{ label }}</h4> {% endif %} {{ title_suffix }} {% block content %} {{ content }} {% endblock %} </div>
Once finished, make sure to save the template, clear Drupal's cache, and then refresh the Blog listing page in the browser. Our Categories block heading is now displayed properly. We have managed to alter the heading of our Categories...