2

I have a page with the path /about that I would like to have a different page layout from the rest of the site.

I have created page.html.twig as my general page template, and page--about.html.twig as the template for this specific page. Both files are in the /templates directory of my theme. However, only the general template is getting used.

Yes, I have cleared the cache.

Appreciate any help!

James

3

You don't say if /about is a different content type or just a node.

If it's a node, you need to use the format:

page--node--1.html.twig

Replace 1 with the about page node id. See the d.o. page for reference info.

If you are trying to have a template for an about content type. You need to add code to your theme like this:

function THEME_NAME_theme_suggestions_page_alter(array &$suggestions, array $variables) {
  // Add content type suggestions.
  if ($node = \Drupal::request()->attributes->get('node')) {
    array_splice($suggestions, 1, 0, 'page__node__' . $node->getType());
  }
}

See this d.o page for more info.

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.