I have done a lot of work in WordPress but want to develop a new site in Drupal 8. I have two specific questions before I start on my site.

  1. Is it possible to inject full HTML pages via PHP into a Drupal 8 environment? I have full HTML content being served from an API for SEO purposes.

If the answer to #1 is NO:

  1. Is it possible to change header and footer based on specific paths? So everything at /articles will get a certain header or footer? In this case I would want to pass an incomplete tag and have the API call close the head tag and provide the body.

Usually you will not inject full HTML pages to Drupal, more likely you will inject your content as node-content. Then use a convenient theme for your needs.

Drupal has - like wordpress - themes. These are nested pieces of HTML code with TWIG syntax for dynamic content.

Unlike, wordpress, you can specify different themes for different URI paths (look for keyword theme_negotiator). I.e., you may configure to use an "article-theme" on path /articles.

But this is only the beginning of a very long story...

  • I just want to confirm that #1 is possible. It is possible to do a full HTML page injection? – carwbrown Jun 16 '16 at 14:18
  • Drupal is written in PHP, so anything you can do with PHP you can do with Drupal. Whether it's a good idea to do some things, and whether Drupal has made them easy for you, is a different story. You'll always find that Drupal developers recommend to do things properly, as "injecting" arbitrary stuff into it could come back to bite you later – Clive Jun 16 '16 at 14:39
  • That is possible but it makes no sense at all. What would you need Drupal for if you inject full pages? – Rainer Feike Jun 16 '16 at 18:01

The problem is that you are trying to think in WP categories when you approach Drupal. If you persist like this, you may succeed, but the result will be very unprofessional and sub-standard.

While the answer is YES, you can serve full custom html pages, by creating them as templates for corresponding end pages, that is almost never a good idea.

In Drupal, header and footer are just regions, into which you can assign blocks. You can create different blocks with different content, assign them to the header and footer, and then set in their block visibility conditions settings to show then on specific pages (there are more settings there as you will see). Then, you will do it right.

Just spend some time to learn the basic Drupal architecture. After having worked on a number of WP projects, I have noticed, that a lot of things that you would do in WP in code, you can architecture in Drupal via the UIs.

Here is a link to the Drupal concepts documentation: https://www.drupal.org/documentation/concepts

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.