Active
Project:
Scheduler
Version:
2.2.2
Component:
Code
Priority:
Minor
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
13 Mar 2026 at 11:12 UTC
Updated:
6 Apr 2026 at 18:56 UTC
Jump to comment: Most recent
We encountered an edge case which might be worth mitigating:
Customer website has banners as node content, which can be shown site-wide or on specific pages. Since we're showing the full banner, the display mode used was full. The banners can also be scheduled. When customer created a site-wide banner with scheduled unpublishing, all site content had the header unavailable_after
fullunavailable_after
From scheduler.module:
/**
* Implements hook_entity_view().
*/
function scheduler_entity_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, string $view_mode) {
// If the entity is going to be unpublished, then add this information to the
// http header for search engines. Only do this when the current page is the
// full-page view of the entity.
// @see https://googleblog.blogspot.be/2007/07/robots-exclusion-protocol-now-with-even.html
if ($view_mode == 'full' && isset($entity->unpublish_on->value)) {
$unavailable_after = date(DATE_RFC850, $entity->unpublish_on->value);
$build['#attached']['http_header'][] = ['X-Robots-Tag', 'unavailable_after: ' . $unavailable_after];
// Also add the information as a meta tag in the html head section.
$unavailable_meta_tag = [
'#tag' => 'meta',
'#attributes' => [
'name' => 'robots',
'content' => 'unavailable_after: ' . $unavailable_after,
],
];
// Any value seems to be OK for the second item, but it must not be omitted.
$build['#attached']['html_head'][] = [$unavailable_meta_tag, 'robots_unavailable_date'];
}
}
This hook could check that we are in the canonical URL of the entity with scheduled unpublishing, and only then alter the HTTP and HTML headers?
Comments