Evolving Web: Structuring Content with Drupal 8

Planet Drupal - 4. April 2018 - 16:11
Structuring Your Drupal Website

Drupal has always been a strong content management platform. The number one reason we use Drupal is because it so easily adapts to our clients’ content models. It enables us to easily map and structure many different types of complex content.

Let’s look at how we go about structuring that content in Drupal, and how we use terminology to define, group and link different types of content.

Content Entities

In Drupal 8, every piece of content is an entity. To structure a site, you want to define different types of entities that will store different types of content.

Let’s take a publishing website as an example. We’re going to create entities for: books, authors, editions, interviews, reviews, book collections, book categories, and so on. You can start by drawing a map of all these nouns. I like mapping out content on a whiteboard because it’s easy to erase and change your mind and it’s bigger than a piece of paper.


Once you’ve mapped all the different types of content that will exist on your site, identify the connections between them. Simply draw arrows arrows between the content types that are related to one another.

For example:

  • A book has an author (or multiple authors): draw an arrow from book to author

  • A book can have editions: draw an arrow from book to edition

  • A book can have reviews, interviews: connect these

  • A book collection has books: group books by collection

  • A book has categories: associate books with topics and categories

Entity Terminology: Bundles, Nodes, Taxonomy, Paragraphs, Blocks

Nodes, taxonomy terms, custom blocks, and paragraphs are all different types of entities. Each entity type has unique properties that make it better suited for different use cases and content types.

Here’s a breakdown of the most important Drupal terminology you need to know to structure your content:

  • Node: A page of content is a node, accessible via its own URL
  • Taxonomy terms: Used to categorize other content, taxonomy terms live in a hierarchy. They can be used to filter content and create unique landing pages.
  • Paragraphs: Content that lives within other content and doesn’t need a dedicated URL is a paragraph.
  • Custom Block: Any content that will be reused throughout the site becomes a custom block. You can also embed a block in a node.
  • Bundle: An entity sub-type is a bundle. Usually, bundles can have have unique fields and settings.
  • Field: A field is a component of the content, i.e. an ISBN, author’s name, or book title
Applying this Model to our Example Project

Here’s how we would decide which entity type to use for each content type:

  • Books and authors become nodes

  • Book categories become taxonomy terms

  • Interviews, reviews and editions could be paragraphs

  • Books and authors would be node bundles (aka content types)

  • A book category is a taxonomy bundle (aka vocabulary)

  • A book collection is a block bundle (block type)

  • Reviews and interviews are paragraph bundles (aka paragraph types)

  • A book collection that needs to be displayed on several pages becomes a block

Focusing on Each Entity to Create Fields

Once you’re looking at a book, you can start to think about what defines a book.

Ask yourself:

  • What information should it have?

  • Which information needs to be displayed?

  • How will we filter and order this content?

  • Will there be a single value for the field or multiple values?

List the various components of the content: title, author, ISBN, covers, genres, editions, reviews, interviews. Each of these will be a field.

Fields in Drupal can be single value (for example, each book has a single ISBN number) or multi-value (a book can have multiple reviews or authors). There are many other fields types that can store the content in a certain way that will affect how it can be displayed or used later (text, date, number, email, link, etc). A field that links one entity to another is a ‘reference’ field.

Information Architecture

So far we’ve talked about structuring your content using entities and bundles. But how do users actually access your content? When you’re building out your site map, you’ll probably picture top-level pages. These may link to dynamic lists of content, or they may have sub-pages that are added beneath them.

Linking to Content

In Drupal, we have three main ways to link to content: menus, views, and fields. In general, this is how we use them:

Menus are for static content: Menus are a static hierarchy of content. If you’re creating permanent content on the site that will be relevant for a long time, you’ll probably link to it through a menu.

Views are for dynamic content: Content that is ‘dynamic’ that will be added to frequently and is too abundant to add to a menu will probably be listed and linked to via views (the Drupal term for ‘list of content’).

Entity reference fields or link fields: You can also explicitly add a link from one content item to another using an entity reference field or a link field. For example, if you have a book and you want to have it link to three other hand-selected ‘related books’, you could create a ‘Content’ reference field for this.

You can go through your site map and figure out which pages are static (linked to by the menu) and dynamic content (linked via views). Landing pages tend to be connection pages. For example, a landing page might live in the menu, list a bunch of dynamic pages and also include explicit links to other pages via ‘calls to action’.  

Applying Menus and Views to Our Example

Using our example, you may have a static page for ‘About Us’, ‘Contact Information’, or ‘History of Publishing’. These would be created as pages and linked to via the menu.

You may also have a page that lists all the books and another that lists all the authors. Because your lists of books and authors are likely to change often, these lists should be created using views. When you add a new book or a new author, it automatically appears in the list.

Taxonomies make creating lists more interesting because we can create lists of content that are filtered by a particular taxonomy term. For example, if ‘prize winning’ is a book category, a taxonomy allows us to create a list of all the books that are ‘prize-winning’.

Finally, you might have a landing page for an upcoming book tour that includes details about the tour, a link to the book being promoted, and also links to other books by the author.


There are many more things to know to build a site with Drupal. But when you’re planning out your content, you simply need to be able to draw out the structure and communicate this with your team. Knowing the basic Drupal concepts will help you communicate clearly and think about the site’s architecture at a high level.

To read about a real-life project in which we built out book content in Drupal 8, read about our project for Princeton University Press.

+ more awesome articles by Evolving Web

Windows entschlacken

heise online Newsticker - 4. April 2018 - 16:00
Aufräumen auf dem Windows-Laufwerk ist riskant: Schnell sind Windows oder Anwendungen beschädigt oder gar unersetzliche eigene Dateien verloren. Wie Sie überflüssige Platzfresser aufspüren und beseitigen, hat c't zusammengetragen.

Darknet-Drogenhandel bedient "letzte Meile"

heise online Newsticker - 4. April 2018 - 15:30
Weil die Darknet-Märkte völlig jenseits staatlicher Regulierung operieren, gelten sie als ökonomisches Labor. Neueste Forschungsergebnisse wecken jedoch Zweifel an dieser These.

Mehr Sicherheit: Update für Arduinos Linuxboard Yùn

heise online Newsticker - 4. April 2018 - 15:30
Sicherer, robuster und endlich Open Source: Arduino hat ein Update für den Yùn angekündigt, der einen Linux Mikroprozessor mitbringt. Ende April soll es lieferbar sein.

Ausblick auf Linux 4.17: HDCP-Support und Kahlschlag beim Architektur-Support

heise online Newsticker - 4. April 2018 - 15:00
Der Linux-Kernel soll die Kopierschutztechnik HDCP lernen und den Support für AMDs moderne Grafikkarten verbessern. Außerdem wollen die Entwickler den Code für acht Architekturen rauswerfen, um die sich kaum noch jemand schert.

Intel beantragt Patent auf Bitcoin-Mining-Chip

heise online Newsticker - 4. April 2018 - 15:00
Das Schürfen von Digitalwährungen boomt, aber der Energiebedarf ist hoch und gerät zunehmend in die Kritik. Intel hat nun ein energiesparendes Chip-Design für Krypto-Mining zum Patent angemeldet.

Nvidia patcht mehrere Lücken in GPU-Treibern

heise online Newsticker - 4. April 2018 - 14:30
Lücken in mehreren Nvidia-Grafikkartentreibern können unter anderem für die Code-Ausführung aus der Ferne missbraucht werden. Gepatchte Versionen stehen zum Download bereit.

Datenschützer nach Sicherheitslücke bei Obike alarmiert

heise online Newsticker - 4. April 2018 - 14:30
Der Leihfahrrad-Anbieter Obike könnte Ärger wegen eines Datenlecks bekommen: Die Berliner Datenschutzbeauftragte hat ein Prüfverfahren eingeleitet. Grund für die Panne soll ein Serverumzug gewesen sein, sagt das Unternehmen. Cloudflare bietet datenschutzfreundlichen und schnellen DNS-Dienst

heise online Newsticker - 4. April 2018 - 14:30
Eine öffentliche Namensauflösung unter einer leicht zu merkenden IP-Adresse soll mehr Tempo und vor allem mehr Privatsphäre bringen. Cloudflare will keine Daten speichern und das betagte DNS-Protokoll sicherer machen.

Shure SE112-BT1: Bluetooth-In-Ears mit Sound Isolating

heise online Newsticker - 4. April 2018 - 14:00
Der SE112-BT1 ist der günstigste Bluetooth-Kopfhörer von Shure. Das merkt man den In-Ears klanglich jedoch nicht an. Auch in anderen Bereichen gefällt der SE112. Ob es auch größere Kritikpunkte gibt, darüber klärt der Testbericht von TechStage auf.

Bauverband: Fachkräftemangel ist Hauptproblem bei Breitbandausbau

heise online Newsticker - 4. April 2018 - 14:00
Der Internet-Breitbandausbau ist kein Problem des Geldes, sagt ein Fachmann - sondern der mangelnden Kapazitäten. Deswegen sei der ehrgeizige Zeitplan der Bundesregierung nicht zu halten.

Flocon de toile | Freelance Drupal: Working with the Drupal Commerce 2 checkout flows

Planet Drupal - 4. April 2018 - 14:00

Drupal Commerce 2 allows to define out of the box multiple checkout flows, allowing to customize according to the order, the product purchased, the customer profile this buying process and modify it accordingly. This is an extremely interesting feature, in that it can simplify as much as necessary this famous checkout flows. Do you sell physical (and therefore with associated delivery) and digital (without delivery) products? In a few clicks you can have two separate checkout flows that will take into account these specificities.

Vorwerk Kobold VR200 im Test: unkomplizierter und gründlicher Saugroboter

heise online Newsticker - 4. April 2018 - 13:30
Der Firmenname Vorwerk steht für hohe Qualität bei anspruchsvollen Preisen. TechStage hat den Kobold VR200 ausprobiert und zeigt, wie sich der einfach zu bedienende Saugroboter in der Praxis schlägt.

Caboost - Außenbordmotor fürs Fahrrad

heise online Newsticker - 4. April 2018 - 13:00
Ein 3. Rad mit Akku und E-Motor soll herkömmliche Fahrräder anschieben - zu einem Fünftel der Kosten eines E-Bikes.

init – der Wochenausblick: DecompileD, SensAbility und Autismus

heise online Newsticker - 4. April 2018 - 13:00
Die Woche nach Ostern ist beinahe so ruhig wie die nach Weihnachten. Dennoch gibt es zwei Events an der WHU und in Dresden, einen interessanten Kinostart, ein paar neue Alben und wichtige Gedenktage.

Linux 4.16 freigegeben: Spectre-v1-Schutz, längere Akkulauzeit und bessere Performance

heise online Newsticker - 4. April 2018 - 13:00
Mehr Akkulaufzeit und Schutz vor der Prozessorlücke Spectre v1 sind zwei Highlights des neuen Linux-Kernels. Der integrierte Hypervisor unterstützt jetzt AMDs Speicherverschlüsselung. Außerdem läuft Linux auch als Gast unter einem Hardware-Partitionierer.

Lullabot: Continuous Integration in Drupal 8 with Travis CI

Planet Drupal - 4. April 2018 - 12:07

This article is the second in our series on Continuous Integration tools for Drupal 8, which started with CircleCI. This time, we explore Travis CI.

Travis CI is the most well known CI tool for open source projects. Its setup process is straightforward and it offers a lot of flexibility and resources to implement Continuous Integration for any kind of project. In this article we will implement the same set of jobs that we did with CircleCI and then compare both tools.


This article makes references to the following resources:

Browse the demo project to discover where the CI components are placed, then use the one-line installer to add these components automatically to your project.

The goal

We want to run the following jobs in a Drupal 8 project when someone creates a pull request:

To accomplish the above, we will use the following tools in Travis CI:

  • Drush, Drupal’s command line interface, to perform Drupal-related tasks like installing Drupal or updating the database.
  • Docker Compose, via docker4drupal, to build the environment where Behat tests run.
  • Robo, a PHP task runner, to define a set of tasks for each of the above jobs.

Here is a screenshot of the Travis CI dashboard with the above setup in place:


Now, let’s see how this has been set up. If you want to dive straight into the code, have a look at the demo Drupal 8 repository.

Setting up Travis CI

Travis CI requires the presence of a .travis.yml file at the root of the repository that dictates how it will build and test the project. I have used this installer that adds the following files:

Additionally, a few dependencies are added via Composer, which are required for the CI jobs.

After adding the above files to the repository, it’s time to give Travis CI access to it. Open https://travis-ci.org and authenticate there with your GitHub account. Next, add the repository at the Travis CI dashboard as shown below:


That’s it! After this, future changes to the repository should trigger builds at Travis CI. If you create a pull request, you will see a status message like the following one:

undefined Seeing the jobs at work

Here is an excerpt of the .travis.yml file. We are leveraging Travis’ build matrix for spinning up three jobs that run in parallel:

env: matrix: - JOB=job:check-coding-standards - JOB=job:run-unit-tests - JOB=job:run-behat-tests install: - composer --verbose install script: - vendor/bin/robo $JOB

The script section is called three times: one for each value assigned to the $JOB variable. It calls a different Robo task each time. We decided to write the implementation of each job as Robo tasks because:

  • It makes the .travis.yml file easier to read and maintain.
  • It makes the job implementations portable between CI tools.
  • It gives developers an opportunity to run the jobs locally.

If you are curious what a Robo task looks like, here is the implementation of the one that runs Behat tests:

/** * Command to run behat tests. * * @return \Robo\Result * The result of the collection of tasks. */ public function jobRunBehatTests() { $collection = $this->collectionBuilder(); $collection->addTaskList($this->downloadDatabase()); $collection->addTaskList($this->buildEnvironment()); $collection->addTask($this->waitForDrupal()); $collection->addTaskList($this->runUpdatePath()); $collection->addTaskList($this->runBehatTests()); return $collection->run(); } Building the environment with Docker Compose

The build environment task shown above, $this→buildEnvironment(), uses Docker Compose to build a Docker environment where the Drupal site will be configured, the database will be updated, and finally, Behat tests will run.

In contrast with CircleCI, where we define the mix of Docker images that the test environment will use to run the jobs, Travis CI offers two environments (Precise and Trusty) with common pre-installed services. Trusty has everything that we need for checking coding standards or running PHPUnit tests, but Behat tests require more setup which we find easier to manage via Docker Compose.

Here are the contents of the build environment task. For simplicity, we have removed a few unrelated lines:

/** * Builds the Docker environment. * * @return \Robo\Task\Base\Exec[] * An array of tasks. */ protected function buildEnvironment() { $force = true; $tasks = []; $tasks[] = $this->taskFilesystemStack() ->copy('.travis/docker-compose.yml', 'docker-compose.yml', $force); $tasks[] = $this->taskExec('docker-compose pull --parallel'); $tasks[] = $this->taskExec('docker-compose up -d'); return $tasks; }

The above task uses this docker-compose.yml file to build the environment.

Generating and visualizing coverage reports

Travis CI does not support storing artifacts like CircleCI does. Therefore, we need to use a third-party service to host them. Travis documentation suggests either uploading them to an Amazon S3 bucket or using Coveralls, a hosted analysis tool. We chose the latter because it posts a summary in each pull request with a link to the full coverage report.

Setting up Coveralls is straightforward. Start by opening https://coveralls.io and then, after authenticating with your GitHub account, use their browser to find and connect to a repository, like this:


Next, it is recommended to review the repository settings so we can customize the developer experience:


With that in place, new pull requests will show a status message with a one-line summary of the coverage report, plus a link to the full details:


Finally, when we click on Details, we see the following coverage report:

undefined A comparison to CircleCI

CircleCI can do all that Travis CI does with less setup. For example, coverage reports and Behat screenshots can be stored as job artifacts and visualized at the CircleCI dashboard. Additionally, CircleCI’s Command Line Interface gives a chance to developers to debug jobs locally.

Travis CI shines on flexibility: for example, only the Behat job uses Docker Compose to build the environment while the rest of the jobs use the Trusty image. Additionally, there is a huge amount of articles and documentation, which you will surely find helpful when tweaking the jobs to fit your team's needs.

If you liked Travis CI, check out this installer to get started quickly in your Drupal 8 project.

What next?

We aren’t sure about which tool to pick for our next article in this series on CI tools for Drupal 8. Do you have a preference? Do you have feedback on what you’ve found relevant about this article? Please let us know by posting a comment.


Chinesische Raumstation Tiangong 1 über dem Südpazifik verglüht

heise online Newsticker - 4. April 2018 - 12:00
In der Nacht zum Montag ist die chinesische Raumstation wie prognostiziert in die Atmosphäre eingetreten und verglüht. Das geschah über dem Südpazifik, weitab der Landmassen, die auch hätten betroffen sein können.

Online-Brauchtum "Aprilscherz": Von Nano-Tinkturen und höheren Mächten

heise online Newsticker - 4. April 2018 - 11:00
Der erste Tag im April bringt wie gewohnt auch im Internet Scherzhaftes und nicht Ernst Gemeintes hervor. Die Redaktion hat einige Fundstücke zusammengestellt - von Hardware bis Bot, von Bildung bis Religion ist einiges dabei.

Ecuador: Assange verpflichtete sich zu Verzicht auf Politisches

heise online Newsticker - 4. April 2018 - 10:30
Assange habe sich sehr wohl dazu verpflichtet, sich nicht zu inneren Angelegenheit anderer Staaten zu äußern, wehrt sich Ecuador in dem Streit, den Internet-Zugang von Julian Assange in der Londoner Botschaft zu unterbinden.