2 * Implements hook_html_head_alter().
4 function {{ machine_name }}_html_head_alter(&$head_elements) {
5 foreach ($head_elements as $key => $element) {
6 if (isset($element['#attributes']['rel']) && $element['#attributes']['rel'] == 'canonical') {
7 // I want a custom canonical URL.
8 $head_elements[$key]['#attributes']['href'] = mymodule_canonical_url();