Problem/Motivation

We're using drupal_block() to render the page title, but when the page title is updated, it's still rendering the previous title. It seems to be displaying a cached version of the block, and doesn't update until the render cache is cleared.

Steps to reproduce

1. Verify that your render cache is not disabled in a settings.php file with

$settings['cache']['bins']['render'] = 'cache.backend.null';

Comment out that line if necessary.
2. Add this to a twig template such as node--page--full.html.twig:

{{ drupal_block('page_title_block', { label_display: false }) }}

3. You should now have two page titles on the page. (The default one and the one manually rendered in the twig template.)
4. Edit the page and change the page title.
5. View the edited page and note that the default page title has been updated, but the twig title is still showing the previous title.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

CommentFileSizeAuthor
#8 Screenshot From 2026-02-08 22-04-40.png56.63 KBboddy

Issue fork twig_tweak-3569103

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

richarddavies created an issue. See original summary.

richarddavies’s picture

Title: drupal_block cache issue » drupal_block cache issue - displays previously cached version
Issue summary: View changes

nickolaj made their first commit to this issue’s fork.

nickolaj’s picture

Status: Active » Needs review

The `url` cache context added for TitleBlockPluginInterface was not bubbling up to the parent render array. This patch merges cache metadata from `$build['content']` to ensure contexts are properly applied.

richarddavies’s picture

Status: Needs review » Needs work

I applied this patch, but I'm still having the same issue.

boddy’s picture

Assigned: Unassigned » boddy
boddy’s picture

Assigned: boddy » Unassigned
Status: Needs work » Needs review
StatusFileSize
new56.63 KB

Fixed the drupal_block title cache issue

If the block is TitleBlockPluginInterface, tried to get the entities from $this->routeMatch, grab their cache tags, and copy those tags into a 'content' child element.

Screenshot%20From%202026-02-08%2022-04-40.png

richarddavies’s picture

Status: Needs review » Reviewed & tested by the community

Thank you! I've confirmed that the MR now resolves this issue. The updated page title is correctly displayed.

anybody’s picture

Issue tags: +Needs tests

Could we have a test for this to ensure it doesn't break again in the future and works as expected?

anybody’s picture

Version: 3.4.1 » 4.x-dev

Needs to go into 4.x first

anybody’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs rebase

Needs rebase