Maybe I'm asking the wrong questions on google, but I can't seem to find a solution to what I'm trying to accomplish.

We've created a Drupal 8 site and we need to add the existing header and footer to an external site so that it includes our site branding.

What is the best solution to accomplish this?

I have some initial thoughts, but feel like I'm way off base:

  1. Pull the <header> and <footer> out of the page.html.twig template and put them into a separate header.html.twig and footer.html.twig template. (My base theme is bootstrap barrio)
  2. Create a custom API that exposes the html from the header and footer twig templates. (I'm not sure if this even possible)
  3. Using the custom API, expose any paths to custom CSS/JS required for theming.

Then the external website would just call the API, grab the html/css/js and put all the gathered resources on their pages.

Is the above on the right track or am I completely wrong? If I am on the right track, how would I accomplish #2?

  • Speaking of my own experience and my own mistakes, this is wrong by concept. Don't do it at all, this is doomed to fail on everything but the simplest cases. If you intentionally want to make your own life harder, you could look how Twig Tweak renders single regions: git.drupalcode.org/project/twig_tweak/blob/8.x-2.x/src/…
    – Hudri
    Apr 9, 2019 at 22:08
  • @Hudri not doing it is not an option, but I am open to new ideas/concepts. How do you propose including site branding from a single site on multiple other websites?
    – neuquen
    Apr 9, 2019 at 22:18

1 Answer 1


I think creating a service REST API to be consumed by the client sites is the cleanest solution.

This has been implemented in Drupal 7 with sharedblocks but there no Drupal 8 port at this time.

Studying this module would give you a solid foundation on how to accomplish your task in Drupal 8.

Based on the same concept there is also distributed_blocks module but again does not seem to have a Drupal 8 port.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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