Search code examples
javascripthtmlmeta-tags

Added meta tags not picked up by metatagscheck.com


I have added title and description meta tags to the top of my head tag. After the page is loaded I can see the meta tags added in the source page.

However when I check it using http://www.metatagscheck.com/, the tags are not there.

<script type='text/javascript'>
    var title=document.createElement('meta');
    title.name="title";
    title.content="Wholesale Prices of Manufacture, Distributors, Traders, Suppliers for GCC &amp; Africa";

    var description=document.createElement('meta');
    description.name="description";
    description.content="Find quality products over the world to get it at your place in GCC and Africa sourced through Manufacturers, Suppliers, Wholesalers, from the UAE, India, China, Turkey, Europe and US.";
    document.head.insertBefore(description, document.head.firstElementChild);
    document.head.insertBefore(title, document.head.firstElementChild);
</script>

Solution

  • The tool http://www.metatagscheck.com/ likely¹ doesn’t execute JavaScript on the page it tests. This is common for many tools (example: W3C’s HTML5 validator).

    If you add the meta tags as HTML to the document (instead of adding them via JavaScript), the tool should be able to read them. Like it does read the title².


    ¹ We can only guess here, as its source code doesn’t seem to be published.

    ² The title element is different from the meta-title element. A meta-title element is invalid in HTML5 (it isn’t registered, so it’s not allowed to use it).