I have multiple pages with different content type. All the pages 1st path component is same. So, I want to define a custom twig page template to these pages by their 1st path component.

Eg. I have pages with the URL like program/one, program/two, program/three and program/ten from the different content type and I want to apply page--program.html.twig template only these specific pages by checking their 1st path component (eg. program/*).

Anyone help me, how to do this?

  • See hook_theme_suggestions_alter – Beebee May 11 '18 at 8:40
  • 1
    In this case you don't need this, because path components are added to page templates automatically, so page--program.html.twig should work out of the box for ' /program/*' – 4k4 May 11 '18 at 9:56
  • 1
    @4k4 I assumed he had nodes with pathauto configured as /program/*. IIRC, aliases are not counted for such template suggestions. He has to either use page--node--[nid].html.twig or make the suggestions himself. If that's the case @PunyaRuchal see: drupal.stackexchange.com/questions/205567/… – Beebee May 11 '18 at 10:51

Your Answer

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

Browse other questions tagged or ask your own question.