Remove duplicated front page seo attributes

Public

WARNING: Use with care on multilingual sites!

Get raw version
php
  1. /*
  2.  * Implemetation of hook_html_head_alter.
  3.  */
  4. function CUSTOMTHEME_html_head_alter(&$head_elements) {
  5. if (drupal_is_front_page()) {
  6. foreach ($head_elements as $key => $element) {
  7. if (isset($element['#attributes']['rel']) && ($element['#attributes']['rel'] == 'canonical' || $element['#attributes']['rel'] == 'shortlink') and $element['#attributes']['href'] != '/') {
  8. unset($head_elements[$key]);
  9. }
  10. }
  11. }
  12. }
  13.  
  14. if (drupal_is_front_page()) {
  15. drupal_add_html_head_link(array(
  16. 'rel' => 'canonical',
  17. 'href' => '/',
  18. ));
  19. }