Blogs

EMAIL: info@example.com

Specbee: Working with the Devel module in Drupal 8 to Generate Dummy Content

Working with the Devel module in Drupal 8 to Generate Dummy Content
Karishma
16 Jun, 2020

The Devel module in Drupal 8 is an extremely useful module for developers. The Devel module includes three submodules – the Devel Generate module, Webprofiler module and Kint modules. In this article we will delve into the Devel Generate module and how to work with it.

When building a Drupal website, you want to have a lot of content to check the overall display such as layouts, views, design. Content come in different forms and so it becomes important to test the website out with dummy content before adding live content. Instead of creating dummy content manually, wouldn’t it be nice to add them automatically? That’s where the Devel Generate module for Drupal 8 will come in handy. 

Drupal Devel module

What does the Drupal Devel module do?

Drupal 8 offers tons of helpful modules that can ease the job of a developer. Devel module has several useful features. As discussed previously, there are several modules that are part of Devel; One such is the Devel Generate module. Devel Generate is used for automatically generating sample or dummy content like menu items, taxonomy terms, and nodes. This is helpful if you need to test or showcase your Drupal website with data like dummy users, content, images, and so on. Drupal Devel module can create it all for you in a moment. Devel and its associated submodules are meant to be used on local development environments and should not be enabled on live production sites.

Getting started with the Devel Generate module

Working with the Devel module is as simple as installing it. Let’s get started with the installation and how to use Devel module in Drupal 8. 

Installing

Installing the Devel Generate module for Drupal 8 is like installing any other contributed module. I’m using the Composer to install it since it automatically installs all of the necessary dependencies. Open the terminal, within the project enter the following command.

      $ composer require drupal/devel
     
Next, enable the Devel and Devel Generate module. 

devel module in drupal 8

Generate content using the Devel UI

 1. Go to Configuration. Here you will see a long list of options under Development. Choose Generate Content.

devel module in drupal

 2. The Generate content interface offers a number of options to set before you hit GENERATE:

  • Generate content for all content types or select for specific content type
  • Check the checkbox if want to delete all content of a certain content type before generating new content 
  • Specify how many nodes to generate and how far back the node creation dates should go
  • Specify the maximum number of dummy comments for each node that support comments
  • Set the maximum number of words for the title of each node
  • Hit Generate
     devel module in drupal

     

3. You can see the list of dummy nodes generated by going to admin -> content

devel module

4.This is what an article looks like with a dummy title, image, and body content

devel module in drupal

Helpful hint: If taxonomy and tags are defined, the generate content module will assign tags at random. If you create vocabularies and terms first and then generate the content, you will end up with more useful test data. Devel can generate vocabularies and terms automatically, but they will be in fake Latin. It’s better to create your own vocabularies and terms because it makes testing easier when you have a meaningful taxonomy to work with.

Shefali ShettyApr 05, 2017