|
| 1 | +--- |
| 2 | +title: Decoupled Drupal |
| 3 | +disableTableOfContents: true |
| 4 | +--- |
| 5 | + |
| 6 | +Learn what <q>decoupled Drupal</q> means, how it differs from other ways of using Drupal, and how you can use decoupled Drupal with Gatsby. |
| 7 | + |
| 8 | +## What is Decoupled Drupal? |
| 9 | + |
| 10 | +_Decoupled Drupal_ is the practice of using Drupal as a [headless CMS](/docs/headless-cms/) for your [JAMstack](/docs/glossary/jamstack/) site. Decoupled Drupal separates the content layer from the presentation layer, so that you can use Drupal with whatever frontend you choose. |
| 11 | + |
| 12 | +In a tightly coupled Drupal architecture, themes control your site's appearance. A theme is a collection of HTML-based template files, each of which manages the layout for a particular Drupal node or content type. |
| 13 | + |
| 14 | +When a visitor requests a URL, Drupal retrieves the requested content from the database and merges it with the appropriate template to create an HTML response. The downside of such an architecture is that your site's content is only available as HTML. HTML limits where and how your content can be used. |
| 15 | + |
| 16 | +In a decoupled architecture, Drupal's only responsibility is content. Rather than returning HTML documents, Drupal returns JSON from its [REST](https://www.drupal.org/docs/8/api/restful-web-services-api/restful-web-services-api-overview) or [JSON:API](https://www.drupal.org/docs/8/modules/jsonapi/api-overview) interfaces. Or you can use [GraphQL](/docs/glossary/graphql) by installing the [GraphQL module](https://www.drupal.org/docs/8/modules/graphql). |
| 17 | + |
| 18 | +A decoupled Drupal architecture offers two key advantages over a tightly coupled one. |
| 19 | + |
| 20 | +- **You can use one content management system to serve multiple frontends** — for example, your Gatsby site, your mobile application, and your smart TV application. |
| 21 | +- **You can develop, change, and upgrade the frontend and backend independently of each other. **Upgrading Drupal doesn't require you to modify your site's appearance. |
| 22 | + |
| 23 | +To use Drupal as a content source for Gatsby, add the [`gatsby-source-drupal`](/packages/gatsby-source-drupal/) plugin to your project. As with Gatsby itself, you install the `gatsby-source-drupal` plugin using [npm](/docs/glossary/#npm). |
| 24 | + |
| 25 | +```shell |
| 26 | +npm install --save gatsby-source-drupal |
| 27 | +``` |
| 28 | + |
| 29 | +A decoupled Drupal architecture lets you use the full power of Drupal's content management tools while gaining the performance advantages of a static Gatsby site. |
| 30 | + |
| 31 | +## Learn more about decoupled Drupal |
| 32 | + |
| 33 | +- Watch [Kyle Mathews’ presentation on Gatsby + Drupal](https://2017.badcamp.net/session/coding-development/beginner/headless-drupal-building-blazing-fast-websites-reactgatsbyjs) |
| 34 | +- Documentation for the [GraphQL Drupal module](https://drupal-graphql.gitbook.io/graphql/) |
| 35 | +- [Sourcing from Drupal](/docs/sourcing-from-drupal/) in the Gatsby docs |
0 commit comments