Home Page rel="canonical" We created a home page as node/1850 which is specified in /admin/config/system/site-information.  When I look at the generated code, I see:

&lt;link rel="canonical" href="/node/1850" /&gt;


This results in Google listing the url of the home page as https://dom.ain/node/1850 which is not what we want. 

What is the best way to correct this?  I believe the following is correct.

&lt;link rel="canonical" href="/" /&gt;
You can use metatag module to adjust metatags like these.

After installing you can visit the settings page /admin/config/search/metatag and there is a specific set of metatags to adjust for front page.  Edit those settings and adjust canonical but I believe by default it sets this to [site:url] which should be OK.

Alternatively or if you don't want to install a module just for this you can do it using hook_preprocess_html in your THEMENAME.theme

function THEMENAME_preprocess_html(&amp;$variables) {
  //if not front page do nothing
  if(! \Drupal::service('path.matcher')-&gt;isFrontPage())
    return ;

  //unset if set
  foreach ($variables['page']['#attached']['html_head'] as $key =&gt; &amp;$value) {
    if ($value[0]['#tag'] == 'link' &amp;&amp; $value[0]['#attributes']['rel'] == 'canonical') {
      unset($variables['page']['#attached']['html_head'][$key]);
      break;
    }
  }

  //add canonical
  $canonical = [
    '#type' =&gt; 'html_tag',
    '#tag' =&gt; 'link',
    '#attributes' =&gt; [
      'rel' =&gt; 'canonical',
      'href' =&gt; '/',
    ],
  ];
  $variables['page']['#attached']['html_head'][] = [$canonical, 'canonical'];  
}