Problem/Motivation

Currently theming in Drupal 8 still entails overriding entire templates. So for example a collection of node templates for different content types will result in a number of templates all repeating the entire contents of the node template even though each one may only be overriding a small portion of the template or adding mark-up in one area.

It has always been this way with Drupal by default, most of the solutions in the past to provide more granular targeting and flexibility have either involved modules that comprehensively change how layout is handled with Drupal (with admin configuration and functionality) or complex base themes.

Proposed resolution

Provide Twig Block mark-up in core templates that allows Twig extends to be used when overriding templates in themes, allowing for much more 'surgical' targeting of changes.

Currently a Twig Block is only used on one place (The block.html.twig template ironically) and only around the content output of this template. Adding a much more comprehensive Twig block markup in Core will allow themers to immediately reap the same advantages that are gained by Core templates that extend block.html.twig.

This issue is really for general discussion and to test the waters (I believe that the advantages adding comprehensive Twig Block mark-up make it worthwhile but there maybe some technical objections and/or other problems that would follow.

For a better idea of what I am suggesting see an experimental base theme I have started work on, there is more information in the readme.

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Feature because it is an improvement to the themeing
Issue priority Normal because it will not resolve errors

Comments

valthebald’s picture

Issue tags: +Barcelona2015

Evaluating this during Friday sprint

badrange’s picture

Version: 8.0.x-dev » 8.1.x-dev
Priority: Major » Normal
Issue summary: View changes
Issue tags: +markup

This looks like a great addition to the theme system. At the moment everybody are working hard on getting Drupal 8.0.0 ready, and according to the Drupal release policy the timing is not right to move forward with this feature request at the moment.

valthebald’s picture

Looks like not committable to 8.0, but will be really nice to see twig blocks in 8.1

chris_hall_hu_cheng’s picture

Yes I would agree at this point, no point in messing up the drive to finish 8 ;)

Hopefully I will have an example custom theme for reference by the time it makes sense to look at it again.

chris_hall_hu_cheng’s picture

Status: Active » Postponed

The introduction of the Stable theme in Core was a bit of a gift.

I have started a sandbox project at https://www.drupal.org/sandbox/chris_hall_hu_cheng/2646294 which is basically intended to be a copy of Stable but with Twig block markup, this can be used as an alternative base theme to the default stable.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

xjm’s picture

Very belatedly adding issue credit for the BCN triage work.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

joelpittet’s picture

Status: Postponed » Active

Postponed isn't the right status for this, moving back to active. It was really postponed on the release.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

esolitos’s picture

I am surprised this hasn't taken any interest, seems to me a great feature to have, so may times i've simply copied over the twig from classy/stable jsut to add the twig blocks and then extend it where needed.

Is there another open issue a part from this on the mater maybe which I haven't seen?

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.