skip to Main Content

HTML5 template tags are meant to be completely inert as if the content doesn’t exist in the source but is that the case when Google crawls and then indexes a webpage?

Does anyone have any data that can prove one way or another that Google indexes or doesn’t index content within template tags? Template tags are great but I don’t want to use them if they adversely affect SEO

2

Answers


  1. I was curious about this as well, as I was thinking about using the <template> tag as a form of server-side rendering or pre-rending some content that would be updated via AJAX/JS once the page is ready.

    I checked the Google Webmaster Tools Structured Data Tester to see if it would read microdata out of HTML tags that were placed inside the <template> tag.

    google structured data template tag test

    As you can see from the screenshot, it does seem to read the data that is inside the <template> tag. I wouldn’t consider this a verified answer, but it does suggest that the parser (at least when it comes to HTML microdata) doesn’t ignore content inside <template> tags.

    Login or Signup to reply.
  2. I experienced something today that would confirm it does affect SEO.

    I just received a warning from the Google Search Console about increasing 404 errors, and almost all URL in error are in that form: /some-path/some-page/$%7Bconsent.infoURL%7D.

    Once URL decoded, we can see that ${consent.infoURL} is a variable I use in a template tag, on a href attribute:

    <template data-template="cookie-notice">
        `<div data-cookie-notice class="cookie-notice" role="dialog">
        <span class="cookie-notice-caption">${consent.captionText}</span>
        <a class="cookie-notice-link" href="${consent.infoURL}">${consent.linkText}</a>
        <button data-button-consent type="button" class="cookie-notice-button">${consent.buttonText}</a>
        </div>`
    </template>
    

    So Google Bot indeed follows links in template tags.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search