remove link tags in head I am working on a project involving migrating a site with many static pages to Drupal 8. Since a number of the pages are old blog posts, there's often broken links, broken images, etc. 

For quality assurance, we are using the httrack command line tool to traverse the new Drupal 8 site and report broken links and images. 

It turns out that Drupal 8 is putting some extra &lt;link&gt; tags in the page head (the &lt;head&gt; section of the html, not the header region or anything like that). 

First, when there is a page with a taxonomy term in it, there are links to the term's admin pages in the head, like so:

&lt;link rel="devel-definition" href="/devel/taxonomy_term/226/definition" /&gt;
&lt;link rel="clone-form" href="/entity_clone/taxonomy_term/226" /&gt;
&lt;link rel="token-devel" href="/taxonomy/term/226/devel/token" /&gt;
&lt;link rel="display" href="/taxonomy/term/226/manage-display" /&gt;


These links are on the page even for anonymous users. 

Second, we have media images in our pages, and they are getting weird head link tags, also. For instance, if we have the image inside-a-classroom.jpg, we'll have this: &lt;link rel="image_src" href="Inside A Classroom" /&gt;.

The problem is, httrack is finding these links in head, trying to download them, and returning a 404. And of course it would, because when it spiders, it's not logged on and can't access admin menus. In the case of images, they're not even proper links to the image. 

Is there any way we can turn these off? They are false negatives in our scraping, and make it difficult to quality check our work.
Links like this are handled as attachments to the page.  They are inserted where the Drupal placeholder tags (like head-placeholder) are in the twig file.

To modify these, you need to use hook_page_attachments_alter().  Here's example code that fixes a problem with canonical URLs containing query string not getting generated properly by core (converts &amp; to &amp;amp;).  

/**
 * Implements hook_page_attachments_alter().
 */
function mytheme_page_attachments_alter(array &amp;$attachments) {
  if ( isset($attachments['#attached']['html_head'])) {
    foreach ($attachments['#attached']['html_head'] as $key =&gt; $item) {
      if (in_array("canonical_url", $item)) {
        $href = $item[0]['#attributes']['href'];
        $attachments['#attached']['html_head'][$key][0] = [
          '#type' =&gt; 'inline_template',
          // Formatted to include a newline in page source.
          '#template' =&gt; "{{ href|raw }}
",
          '#context' =&gt; [
            'href' =&gt; '&lt;link rel="canonical" href="' . $href . '"/&gt;',
          ]
        ];
      }
    }
  }
}


In the case of these entity links, these are in the 'html_head_link' area of the attachments.

FYI - This is also related to this core issue.