JavaScript library that simplifies the extraction of HTML meta and Open Graph tags from HTML content or URLs. These tags provide structured metadata for webpages, useful for social media sharing and SEO purposes.

The library is compatible with both server and browser environments, supporting ES6 and CommonJS module systems. ES6 modules are suitable for modern browsers, while CommonJS modules are commonly used in server-side JavaScript environments like Node.js.


  • Lightning-fast performance for optimal efficiency.
  • Versatile compatibility with both Node.js and web browsers.
  • Effortlessly extract HTML meta and Open Graph tags from HTML code or URLs.
  • Seamlessly parse and access metadata such as og:titleog:descriptionog:imagefavicon, and more.
  • Developed using TypeScript to ensure robust type safety.
  • Simple integration into web applications for hassle-free implementation.
  • Comprehensive support for error handling and customization options.

<!– Basic –>
<meta charset=”UTF-8″>
<meta name=”keywords” content=”your, tags”>
<meta name=”description” content=”150 words”>
<meta name=”subject” content=”your website’s subject”>
<meta name=”copyright” content=”company name”>
<meta name=”language” content=”ES”>
<meta name=”robots” content=”index,follow”>
<meta name=”revised” content=”Sunday, July 18th, 2010, 5:15 pm”>
<meta name=”abstract” content=””>
<meta name=”topic” content=””>
<meta name=”summary” content=””>
<meta name=”Classification” content=”Business”>
<meta name=”author” content=”name,”>
<meta name=”designer” content=””>
<meta name=”reply-to” content=””>
<meta name=”owner” content=””>
<meta name=”url” content=””>
<meta name=”identifier-URL” content=””>
<meta name=”directory” content=”submission”>
<meta name=”pagename” content=”jQuery Tools, Tutorials and Resources – O’Reilly Media”>
<meta name=”category” content=””>
<meta name=”coverage” content=”Worldwide”>
<meta name=”distribution” content=”Global”>
<meta name=”rating” content=”General”>
<meta name=”revisit-after” content=”7 days”>
<meta name=”subtitle” content=”This is my subtitle”>
<meta name=”target” content=”all”>
<meta name=”HandheldFriendly” content=”True”>
<meta name=”MobileOptimized” content=”320″>
<meta name=”date” content=”Sep. 27, 2010″>
<meta name=”search_date” content=”2010-09-27″>
<meta name=”DC.title” content=”Unstoppable Robot Ninja”>
<meta name=”ResourceLoaderDynamicStyles” content=””>
<meta name=”medium” content=”blog”>
<meta name=”syndication-source” content=””>
<meta name=”original-source” content=””>
<meta name=”verify-v1″ content=”dV1r/ZJJdDEI++fKJ6iDEl6o+TMNtSu0kv18ONeqM0I=”>
<meta name=”y_key” content=”1e39c508e0d87750″>
<meta name=”pageKey” content=”guest-home”>
<meta itemprop=”name” content=”jQTouch”>
<meta http-equiv=”Expires” content=”0″>
<meta http-equiv=”Pragma” content=”no-cache”>
<meta http-equiv=”Cache-Control” content=”no-cache”>
<meta http-equiv=”imagetoolbar” content=”no”>
<meta http-equiv=”x-dns-prefetch-control” content=”off”>

<!– Apple –>
<meta name=”apple-mobile-web-app-title” content=”My App”> <!– New in iOS6 –>
<meta name=”apple-mobile-web-app-capable” content=”yes”>
<meta name=”apple-touch-fullscreen” content=”yes”>
<meta name=”apple-mobile-web-app-status-bar-style” content=”black”>
<meta name=”format-detection” content=”telephone=no”>
<meta name=”viewport” content=”width=device-width; content=”width = 320; initial-scale=1.0; maximum-scale=1.0; user-scalable=yes; target-densitydpi=160dpi”>

<link href=”/apple-touch-icon.png” rel=”apple-touch-icon” type=”image/png”>
<link href=”touch-icon-ipad.png” rel=”apple-touch-icon” sizes=”72×72″>
<link href=”touch-icon-iphone4.png” rel=”apple-touch-icon” sizes=”114×114″>
<link href=”/startup.png” rel=”apple-touch-startup-image”>

<link href=”” sizes=”114×114″ rel=”apple-touch-icon-precomposed”>
<link href=”” sizes=”72×72″ rel=”apple-touch-icon-precomposed”>
<link href=”×57.png” sizes=”57×57″ rel=”apple-touch-icon-precomposed”>

<!– Safari 9 –>
<link rel=”mask-icon” href=”website_icon.svg” color=”red”>

<!– Internet Explorer –>
<meta http-equiv=”Page-Enter” content=”RevealTrans(Duration=2.0,Transition=2)”>
<meta http-equiv=”Page-Exit” content=”RevealTrans(Duration=3.0,Transition=12)”>
<meta name=”mssmarttagspreventparsing” content=”true”>
<meta content=”IE=edge,chrome=1″ http-equiv=”X-UA-Compatible”/>
<meta name=”msapplication-starturl” content=””>
<meta name=”msapplication-window” content=”width=800;height=600″>
<meta name=”msapplication-navbutton-color” content=”red”>
<meta name=”application-name” content=”Rey Bango Front-end Developer”>
<meta name=”msapplication-tooltip” content=”Launch Rey Bango”s Blog”>
<meta name=”msapplication-task” content=”name=About;action-uri=/about/;icon-uri=/images/about.ico”>
<meta name=”msapplication-task” content=”name=The Big List;action-uri=/the-big-list-of-javascript-css-and-html-development-tools-libraries-projects-and-books/;icon-uri=/images/list_links.ico”>
<meta name=”msapplication-task” content=”name=jQuery Posts;action-uri=/category/jquery/;icon-uri=/images/jquery.ico”>
<meta name=”msapplication-task” content=”name=Start Developing;action-uri=/category/javascript/;icon-uri=/images/script.ico”>
<meta name=”msvalidate.01″ content=”6E3AD52DC176461A3C81DD6E98003BC9″>
<meta http-equiv=”cleartype” content=”on”>

<!– Windows 8 –>
<meta name=”application-name” content=” Contoso” />
<meta name=”msapplication-TileColor” content=” #009900″ />
<meta name=”msapplication-square70x70logo” content=”images/smalltile.png” />
<meta name=”msapplication-square150x150logo” content=”images/mediumtile.png” />
<meta name=”msapplication-wide310x150logo” content=”images/widetile.png” />
<meta name=”msapplication-square310x310logo” content=”images/largetile.png” />
<meta name=”msapplication-notification” content=”frequency=30; polling-uri=notifications/contoso1.xml; polling-uri2=notifications/contoso2.xml; polling-uri3=notifications/contoso3.xml” />

<!– Blog Catalog –>
<meta name=”blogcatalog”>

<!– Rails –>
<meta name=”csrf-param” content=”authenticity_token”>
<meta name=”csrf-token” content=”/bZVwvomkAnwAI1Qd37lFeewvpOIiackk9121fFwWwc=”>

<!– HTML Link –>
<link rel=”alternate” type=”application/rss+xml” title=”RSS” href=””>
<link rel=”alternate” type=”application/atom+xml” title=”Atom 0.3″ href=””>
<link rel=”shortcut icon” type=”image/ico” href=”/favicon.ico”>
<link rel=”fluid-icon” type=”image/png” href=”/fluid-icon.png”>
<link rel=”me” type=”text/html” href=””>
<link rel=”shortlink” href=”″>
<link rel=”archives” title=”May 2003″ href=””>
<link rel=”index” title=”DeWitt Clinton” href=””>
<link rel=”start” title=”Pattern Recognition 1″ href=””>
<link rel=”bookmark”title=”Styleguide” href=””>
<link rel=”search” href=”/search.xml” type=”application/opensearchdescription+xml” title=”Viatropos”>

<link rel=”self” type=”application/atom+xml” href=”″>
<link rel=”first” href=””>
<link rel=”next” href=”″>
<link rel=”previous” href=”″>
<link rel=”last” href=”″>

<link rel=”canonical” href=””>
<link rel=”EditURI” type=”application/rsd+xml” title=”RSD” href=””>
<link rel=”pingback” href=””>
<link rel=”stylesheet” media=”only screen and (max-device-width: 480px)” href=”” type=”text/css”>
<link rel=”wlwmanifest” href=”” type=”application/wlwmanifest+xml”>

<link rel=”help” title=”FAQ” href=”/faq”>
<link rel=”logo” type=”image/svg” href=””>
<link rel=”P3Pv1″ href=”/w3c/p3p.xml”>
<link rel=”publisher” href=””>
<link rel=”image_src” href=”” type=”image/jpeg”>

<link rel=”author” href=”humans.txt” type=”text/plain”>
<link href=”” rel=”original-source”>
<link rel=”profile” title=”Microformats” href=””>
<link rel=”profile” href=”″>

Basic HTML Meta Tags

<meta name="keywords" content="your tags" />
<meta name="description" content="150 words" />
<meta name="subject" content="your website's subject">
<meta name="language" content="ES">
<meta name="robots" content="indexfollow" />
<meta name="revised" content="Friday August 26th 2018 5:55 pm" />
<meta name="abstract" content="">
<meta name="topic" content="">
<meta name="summary" content="">
<meta name="Classification" content="Business">
<meta name="author" content="name">
<meta name="designer" content="">
<meta name="copyright" content="">
<meta name="reply-to" content="">
<meta name="owner" content="">
<meta name="url" content="">
<meta name="identifier-URL" content="">
<meta name="directory" content="submission">
<meta name="category" content="">
<meta name="coverage" content="Worldwide">
<meta name="distribution" content="Global">
<meta name="rating" content="General">
<meta name="revisit-after" content="7 days">
<meta http-equiv="Expires" content="0">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-cache">

OpenGraph Meta Tags

<meta name="og:title" content="The Rock" />
<meta name="og:type" content="fashion" />
<meta name="og:url" content="" />
<meta name="og:image" content="" />
<meta name="og:site_name" content="WWCelebrities" />
<meta name="og:description" content="......" />
<meta name="fb:page_id" content="YOUR ID In profile url after ID#" />
<meta name="og:email" content="" />
<meta name="og:phone_number" content="650-123-4567" />
<meta name="og:fax_number" content="+1-415-123-4567" />
<meta name="og:latitude" content="37.416343" />
<meta name="og:longitude" content="-122.153013" />
<meta name="og:street-address" content="1601 S California Ave" />
<meta name="og:locality" content="Palo Alto" />
<meta name="og:region" content="CA" />
<meta name="og:postal-code" content="94304" />
<meta name="og:country-name" content="USA" />
<meta property="og:type" content="game.achievement" />
<meta property="og:points" content="POINTS_FOR_ACHIEVEMENT" />
<meta property="og:video" content="" />
<meta property="og:video:height" content="640" />
<meta property="og:video:width" content="385" />
<meta property="og:video:type" content="application/x-shockwave-flash" />
<meta property="og:video" content="" />
<meta property="og:video:type" content="video/mp4" />
<meta property="og:video" content="" />
<meta property="og:video:type" content="text/html" />
<meta property="og:audio" content="" />
<meta property="og:audio:title" content="Best Song" />
<meta property="og:audio:artist" content="Best Band" />
<meta property="og:audio:album" content="Best Album" />
<meta property="og:audio:type" content="application/mp3" />

CORS issues (when using the library in the browser)

To circumvent CORS (Cross-Origin Resource Sharing) issues, one approach is to execute the extractFromUrl function from a server-side environment. Alternatively, if you are working in a browser-based setting, you can proxy the request through a free service such as

For instance, you can use the following URL format to access the desired resource: This will allow you to retrieve the necessary data without running into CORS restrictions. By leveraging this method, you can effectively work around CORS limitations and access the desired information seamlessly.

Third Party Tools

The module utilizes the following third-party tools for testing and functionality:

  • Vitest: Next-generation testing framework.
  • Cheerio: A fast, flexible, and lean implementation of core jQuery designed for server-side Node.js.
  • Markdwown-Badges: Badges for your personal developer branding, profile, and projects.


We welcome contributions to the @jcottam/html-metadata module! If you’d like to contribute, please follow these guidelines:

  1. Fork the repository and create a branch.
  2. Make your changes and ensure that the code style and tests pass.
  3. Submit a pull request with a detailed description of your changes.

Forking the Repository

Click on the “Fork” button in the top right corner of the repository page. This will create a copy of the repository under your GitHub account.

Cloning the Forked Repository

git clone

Making Changes

Create a new branch to work on your changes:

git checkout -b feature-branch

Make your desired changes to the codebase, documentation, or any other relevant files.


npm install
npm run build


npm run test

Committing Changes

  1. Stage the changes you have made:
git add .
  1. Commit the staged changes with a descriptive message:
git commit -m "Add feature XYZ"

Pushing Changes

git push origin feature-branch

Issuing a Pull Request

  1. Visit your forked repository on GitHub.
  2. Click on the “New pull request” button next to the branch selection drop-down.
  3. Select the base branch (usually the main branch of the original repository) and the compare branch (your feature branch).
  4. Provide a descriptive title and detailed description of your changes in the pull request.
  5. Click on the “Create pull request” button to submit your pull request for review.

Review and Collaboration

  1. The maintainers of the original repository will review your pull request.
  2. Any feedback or changes required will be communicated through comments on the pull request.
  3. Once the changes are approved, your pull request will be merged into the main repository.


In general, generator can make ~10k records per seconds and use ~80Mb memory for this. That’s mean meta tags generation not be bottleneck with up to 10k RPS. You can recheck in ./benchmark directory.

How to use


import { MetadataGenerator } from 'metatags-generator';

Pure Nodejs

const MetadataGenerator = require('metatags-generator');
const settings = {
  structuredData: true,
  androidChromeIcons: true,
  msTags: true,
  safariTags: true,
  appleTags: true,
  openGraphTags: true,
  twitterTags: true,
  facebookTags: true

const generator = new MetadataGenerator();
const preparedData = generator
  .setRobots('index, follow')
  .setLocalVersion('en_US', '', true)
    name: 'Example app',
    url: '',
    logo: '/path/logo.png',
    primaryColor: '#333333',
    backgroundColor: '#ffffff'
    title: 'Home',
    description: 'This is home page',
    url: '',
    image: '/path/cover.jpg',
    keywords: 'site, app, example, pug',
    locale: 'en_US'
    card: 'summary_large_image',
    site: '@nytimesbits',
    creator: '@nickbilton'

Then you can use HTML output for inject in your page.

Express + Pug example

Install dependencies

npm i express pug metatags-generator

Create files:


const express = require('express');
const { MetadataGenerator } = require('metatags-generator');

const app = express();
const port = 3000;

app.set('views', `${__dirname}`);
app.set('view engine', 'pug');

const generator = new MetadataGenerator();

const data = [
  { title: 'Home', url: '' },
  { title: 'About', url: '' }

const icons = ['/path/icon-72x72.png', '/path/icon-180x180.png'];

const preparedData = generator
  .setRobots('index, follow')
  .setLocalVersion('en_US', '', true)
    name: 'Example app',
    url: '',
    logo: '/path/logo.png',
    primaryColor: '#333333',
    backgroundColor: '#ffffff'
    title: 'Home',
    description: 'This is home page',
    url: '',
    image: '/path/cover.jpg',
    keywords: 'site, app, example, pug',
    locale: 'en_US'
    card: 'summary_large_image',
    site: '@nytimesbits',
    creator: '@nickbilton'

app.get('/', (req, res) => {
  res.render('index', { head: preparedData.head, body: preparedData.body });

app.listen(port, () => {
  console.log(`Example app listening at http://localhost:${port}`);

The author meta tag specifies the author of the web page.

<meta name="author" content="Author's Name">

MDN author


<meta name="description" content="A concise description of the page">

MDN description

Color Scheme

The color-scheme meta tag sets the preferred color scheme for the page.

<meta name="color-scheme" content="light dark">

MDN color-scheme

Theme Color

The theme-color meta tag defines the color of the browser’s UI elements when the page is active.

<meta name="theme-color" content="#f1c2d3">

MDN theme-color


The referrer meta tag specifies the referrer policy for the page.

<meta name="referrer" content="no-referrer">

MDN referrer

HTTP-Equiv Attributes

Content Security Policy

The content-security-policy meta tag specifies the content security policy for the page.

<meta http-equiv="Content-Security-Policy" content="default-src 'self'">

MDN Content-Security-Policy


The refresh meta tag automatically refreshes the page after a specified time interval.

<meta http-equiv="refresh" content="5">

MDN refresh

Link Tags


The rel="stylesheet" link tag links an external stylesheet to the document for styling purposes.

<link rel="stylesheet" href="styles.css">

MDN rel=”stylesheet”

Canonical URL

The rel="canonical" link tag specifies the canonical URL for the document to avoid duplicate content issues.

<link rel="canonical" href="">

MDN rel=”canonical”

Alternate to Another Language

The rel="alternate" link tag provides alternate versions of the current document in different languages.

<link rel="alternate" hreflang="es" href="alternate-language.html">

MDN rel=”alternate”

Manifest for Web Application

The rel="manifest" link tag specifies the location of the web app’s manifest file.

<link rel="manifest" href="app.webmanifest">

MDN rel=”manifest”

RSS Feed

The rel="alternate" link tag can also be used to specify an RSS feed for the document.

<link rel="alternate" type="application/rss+xml" title="RSS Feed" href="rss-feed.xml">

Learn more: MDN rel=”alternate”


Icon-related link tags can be used to specify various icons for the document.

Conditional Loading with Media Queries

Load stylesheets conditionally based on media queries.

<link rel="stylesheet" media="(max-width: 600px)" href="mobile.css">
<link rel="stylesheet" media="(min-width: 601px)" href="desktop.css">

MDN Media Queries

Preloading Resources

Preload resources for improved performance.

<link rel="preload" href="font.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="image.webp" as="image">

MDN rel=”preload”

Prefetching Resources

Prefetch resources for upcoming navigations.

<link rel="prefetch" href="next-page.html">

MDN rel=”prefetch”

Social Media

Open Graph and Twitter Card Tags

Facebook Open Graph tags customize content appearance when shared on social media platforms like Facebook, while Twitter Card tags enhance previews on Twitter.


The type of the content, e.g., “website” or “article”.

<meta property="og:type" content="article">


The URL of the shared content.

<meta property="og:url" content="">


The title of the shared content.

<meta property="og:title" content="Page Title">


The description of the shared content.

<meta property="og:description" content="Description of the content">


An image to display when the content is shared.

<meta property="og:image" content="image.jpg">


The name of the site or app.

<meta property="og:site_name" content="Site Name">


The locale for the content.

<meta property="og:locale" content="en_US">


The type of Twitter card to use.

<meta name="twitter:card" content="summary">


The Twitter handle of the site’s creator.

<meta name="twitter:site" content="@username">


The Twitter handle of the content creator.

<meta name="twitter:creator" content="@author">

When implementing social media tags, it’s important to note that Twitter Card tags (e.g., twitter:titletwitter:description, etc.) are often unnecessary when equivalent Open Graph tags (e.g., og:titleog:description, etc.) are present. Twitter will automatically use Open Graph tags as a fallback when generating previews on its platform. Therefore, you can simplify your implementation by focusing on the Open Graph tags and omitting their Twitter Card counterparts. Twitter Card Fallback Behavior