Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Metatags always use global:frontpage as settings for front. If i edit metatags for my frontpage it has no effect.
I found the problem in metatag.module on line 1228 and beyond:
// The front page has special consideration.
$instance = 'global:frontpage';
if (drupal_is_front_page() && metatag_config_is_enabled($instance)) {
$instance = 'global:frontpage';
// These two parts are sufficient given that the homepage is unique.
$cid_parts = array(
'langcode' => $GLOBALS['language_content']->language,
'url' => $GLOBALS['base_url'] . base_path() . '<front>',
);
// Allow each page in a sequence to have different values.
if (isset($_GET['page'])) {
$cid_parts['page'] = $_GET['page'];
}
// Allow other modules to customize the data using
// hook_metatag_page_cache_cid_parts_alter().
drupal_alter('metatag_page_cache_cid_parts', $cid_parts);
$cid = "output:{$instance}:" . hash('sha256', serialize($cid_parts));
if ($cache = cache_get($cid, 'cache_metatag')) {
$metatags = $cache->data;
}
else {
$metatags = metatag_metatags_view($instance, array());
cache_set($cid, $metatags, 'cache_metatag');
}
$page['content']['metatags'][$instance] = $metatags;
}
// Load any meta tags assigned via metatag_page_set_metatags(). Note: this
// must include the necessary defaults.
else {
$page['content']['metatags'] += metatag_page_get_metatags();
}
What does this if-case actually do for the frontpage?
If i change and make the if-case unused like this:
// The front page has special consideration.
$instance = 'global:frontpage';
if (1==2) {
Metatags seem to work properly on frontpage...
Any ideas?
Comments
Comment #1
toelli CreditAttribution: toelli commentedComment #2
toelli CreditAttribution: toelli commentedComment #3
toelli CreditAttribution: toelli commentedComment #4
DamienMcKennaComment #5
DamienMcKennaThis is a feature. If you want to use a node for the frontpage and use its metatags instead of the global:frontpage tags you have to disable the global:frontpage settings.
If that isn't what you're trying to do, please feel free to reopen this, but please provide further details so I can better understand what you're trying to do. Thanks.