I miss hook_page_alter()!

I want to create a module that adds some configurable markup to page titles (the H1 tag on the HTML document) for full node pageviews of certain, configurable content types. But according to this change record:

You no longer can change $page['content'] (or, generally speaking, $page[$region_name]) into something completely different.

I know I can override twig templates to achieve this, but can I do that without creating a theme? I'd like this to be a reusable module.


The page title is now a block, so you can override its template file.


drupal 8 page title is block so you can use hook

function hook_preprocess_page_title(&$variables) {

     $node = \Drupal::routeMatch()->getParameter('node');
   $variables['title'] = "your custom text here ".$node->getTitle(); 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.