One of the most basic features of modern content management systems is the ability to easily create and schedule content for publication. It would be frustrating to be required to log into your site at an inconvenient time to just click “Publish”.
Strangely, this functionality is not built into Drupal core as you might think. However, as you know from working with Drupal, “there’s a module for that!“. The module you need is the Scheduler module.
From the Project Documentation
Scheduler gives content editors the ability to schedule nodes to be published and unpublished at specified dates and times in the future.
Dates can be entered either as plain text or with calendar popups. To use calendar popups in Drupal 7 you need to install the Date Popup module, which is part of the Date module. In Drupal 8 this is built into Core.
Scheduler integration with other 8.x modules
- If you use the core Content Moderation features then you should also install the Scheduler Content Moderation Integration sub-module.
- Scheduler provides Conditions, Actions and Events for use in the Rules module.
- When generating new test content via Devel Generate Scheduler can add publishing and unpublishing dates automatically.
- Scheduler provides drush commands to run Scheduler’s lightweight cron.
- Scheduler provides tokens for the scheduled dates.
How To Publish Content With the Scheduler Module
- Head over to https://www.drupal.org/project/scheduler and install the module. There are no other required modules unless you’re using Content Moderation and Workflows (as noted above). If you’re using the Rules module, install both, otherwise just install the Scheduler module.
- Head over to Configuration -> Content Authoring -> Scheduler and click on the Lightweight Cron tab. It is important to note that Scheduler will run as long as cron jobs are properly set up on your Drupal site. If you would rather change the frequency of the task, you can use the lightweight cron settings to manage that. For more information on Drupal 8 Cron Jobs see https://www.drupal.org/docs/user_guide/en/security-cron.html.
- Since all you’re doing is scheduling a publication date and time, there’s actually nothing that needs to change here.
- To configure this for a content type, go to Structure -> Content Types and click on a content type (for example Article) and click on the Scheduler option .
- Put checkmarks in Enable scheduled publishing for this content type and Enable scheduled unpublishing for this content type.
- You’ll notice you have a lot of options now. If you select Change content creation time to match the scheduled publish time, the create date and time will be updated to match. If you select Require scheduled publishing/unpublishing, an editor will be required to enter dates and times for any node they add.
- On the Node Edit Page Layout dropdown, you can change how the scheduling options are displayed.
The Scheduler module offers some robust flexibility for Drupal Site Builders and Editors around the publication of nodes, not to mention not having to log in to publish a node at midnight!