diff -u b/core/modules/node/src/Controller/NodeViewController.php b/core/modules/node/src/Controller/NodeViewController.php --- b/core/modules/node/src/Controller/NodeViewController.php +++ b/core/modules/node/src/Controller/NodeViewController.php @@ -28,6 +28,8 @@ if (!$node->urlInfo($rel)->access()) { continue; } + + // Set the node path as the canonical URL to prevent duplicate content. $build['#attached']['html_head_link'][] = array( array( // Set the node path as the canonical URL to prevent duplicate content. diff -u b/core/modules/node/src/Tests/NodeViewTest.php b/core/modules/node/src/Tests/NodeViewTest.php --- b/core/modules/node/src/Tests/NodeViewTest.php +++ b/core/modules/node/src/Tests/NodeViewTest.php @@ -36,7 +36,7 @@ $this->assertEqual($result[0]['href'], $node->url()); $this->drupalLogout(); - $this->drupalGet($node->getSystemPath()); + $this->drupalGet($node->urlInfo()); $result = $this->xpath('//link[@rel = "version-history"]'); $this->assertEqual(count($result), 0); @@ -45,7 +45,7 @@ $this->assertEqual(count($result), 0); $result = $this->xpath('//link[@rel = "canonical"]'); - $this->assertEqual($result[0]['href'], \Drupal::url("node/{$node->id()}")); + $this->assertEqual($result[0]['href'], $node->url()); } /** diff -u b/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module --- b/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -93,6 +93,11 @@ $route_match = \Drupal::routeMatch(); if ($route_match->getRouteName() == 'entity.taxonomy_term.canonical' && ($term = $route_match->getParameter('taxonomy_term')) && $term instanceof TermInterface) { foreach ($term->uriRelationships() as $rel) { + // Only add links the user is allowed to visit. + if (!$term->urlInfo($rel)->access()) { + continue; + } + // Set the URI relationships, like canonical. $page['#attached']['html_head_link'][] = array( array( @@ -110,11 +115,6 @@ $route_match = \Drupal::routeMatch(); if ($route_match->getRouteName() == 'entity.taxonomy_term.canonical' && ($term = $route_match->getParameter('taxonomy_term')) && $term instanceof TermInterface) { foreach ($term->uriRelationships() as $rel) { - // Only add links the user is allowed to visit. - if (!$term->urlInfo($rel)->access()) { - continue; - } - // Set the URI relationships, like canonical. $page['#attached']['html_head_link'][] = array( array(