All Projects → tannerdolby → eleventy-plugin-metagen

tannerdolby / eleventy-plugin-metagen

Licence: MIT License
An Eleventy shortcode that generates metadata for Open Graph, Twitter card, generic meta tags and a canonical link.

Programming Languages

javascript
184084 projects - #8 most used programming language
Nunjucks
165 projects

Projects that are alternatives of or similar to eleventy-plugin-metagen

eleventy-load
Resolve dependencies and post-process files in your Eleventy project
Stars: ✭ 28 (+0%)
Mutual labels:  eleventy, eleventy-plugin
eleventy-plugin-pwa
An eleventy plugin to generate service-worker for PWA. Powered by Google Workbox
Stars: ✭ 46 (+64.29%)
Mutual labels:  eleventy, eleventy-plugin
eleventy-plugin-svelte
Eleventy plugin to support svelte templates
Stars: ✭ 40 (+42.86%)
Mutual labels:  eleventy, eleventy-plugin
eleventy-plugin-toc
11ty plugin to generate a TOC from page content
Stars: ✭ 45 (+60.71%)
Mutual labels:  eleventy, eleventy-plugin
eleventy-plugin-unfurl
Unfurl links into rich cards, as seen in places like Slack and Twitter
Stars: ✭ 37 (+32.14%)
Mutual labels:  eleventy, eleventy-plugin
eleventy-plugin-prismic
Eleventy plugin and shortcodes to fetch and present Prismic content
Stars: ✭ 39 (+39.29%)
Mutual labels:  eleventy, eleventy-plugin
eleventy-navigation
A plugin for creating hierarchical navigation in Eleventy projects. Supports breadcrumbs too!
Stars: ✭ 88 (+214.29%)
Mutual labels:  eleventy, eleventy-plugin
eleventy-upgrade-help
Helper plugin when upgrading your Eleventy project to a new major version.
Stars: ✭ 33 (+17.86%)
Mutual labels:  eleventy, eleventy-plugin
eleventy-plugin-cloudinary
An Eleventy shortcode that allows you to add an image from your cloudinary account
Stars: ✭ 28 (+0%)
Mutual labels:  eleventy, eleventy-plugin
eleventy-plugin-social-images
Create dynamic images sized for social media tags for your Eleventy content.
Stars: ✭ 35 (+25%)
Mutual labels:  eleventy, eleventy-plugin
eleventy-plugin-inclusive-language
A linter plugin to check for inclusive language in markdown files.
Stars: ✭ 32 (+14.29%)
Mutual labels:  eleventy, eleventy-plugin
eleventy-plugin-embed-tweet
A plugin for embedding tweets on the server side during build time
Stars: ✭ 24 (-14.29%)
Mutual labels:  eleventy, eleventy-plugin
virtual-lolly
JAMstack demo site - prerendered with serverless API fallbacks
Stars: ✭ 110 (+292.86%)
Mutual labels:  eleventy
trailing-slash-guide
Understand and fix your static website trailing slash issues!
Stars: ✭ 255 (+810.71%)
Mutual labels:  eleventy
bymattlee-11ty-starter
A starter boilerplate powered by 11ty, Sanity, Gulp, Tailwind CSS, rollup.js, Alpine.js and Highway.
Stars: ✭ 27 (-3.57%)
Mutual labels:  eleventy
YATAS
Yet Another Tailwind Alpine Starter
Stars: ✭ 18 (-35.71%)
Mutual labels:  eleventy
11ty-sass-skeleton
Featuring absolutely nothing beyond a base HTML5 template and the essential setup to watch and compile your Sass alongside 11ty.
Stars: ✭ 174 (+521.43%)
Mutual labels:  eleventy
eleventy-duo
Eleventy Duo is a minimal and beautiful Eleventy theme for personal blogs.
Stars: ✭ 146 (+421.43%)
Mutual labels:  eleventy
11ty-blog-starter
11ty v1.0, Tailwind v3. Works when JS is disabled
Stars: ✭ 55 (+96.43%)
Mutual labels:  eleventy
smol-11ty-starter
Extremely minimal Eleventy starter to kickstart a simple multi-page site / a nearly opinionless foundation to continue building on.
Stars: ✭ 61 (+117.86%)
Mutual labels:  eleventy

eleventy-plugin-metagen

An Eleventy shortcode that generates document metadata containing: Open Graph, Twitter card, generic meta tags and a canonical link.

Installation

Install the plugin from npm:

npm install eleventy-plugin-metagen

Then add it to your Eleventy Config file:

const metagen = require('eleventy-plugin-metagen');

module.exports = (eleventyConfig) => {
    eleventyConfig.addPlugin(metagen);
};

What does it do?

The plugin turns 11ty shortcodes like this:

<head>
{% metagen
    title="Eleventy Plugin Meta Generator",
    desc="An eleventy shortcode for generating meta tags.",
    url="https://tannerdolby.com",
    img="https://tannerdolby.com/images/arch-spiral-large.jpg",
    img_alt="Archimedean Spiral",
    twitter_card_type="summary_large_image",
    twitter_handle="tannerdolby",
    name="Tanner Dolby",
    generator="eleventy",
    comments=true,
    css=["style.css", "design.css"],
    inline_css="h1 { color: #f06; }",
    js=["foo.js", ["bar.js", "async"]],
    inline_js="console.log("hello, world");",
    custom=[["meta", "", {name: custom-tag, content: foo }]]
%}
</head>

into <meta> tags and other document metadata like this:

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Eleventy Plugin Meta Generator</title>
    <meta name="author" content="Tanner Dolby">
    <meta name="title" content="Eleventy Plugin Meta Generator">
    <meta name="description" content="An eleventy shortcode for generating meta tags.">
    <meta name="generator" content="eleventy">
    <!-- Open Graph -->
    <meta property="og:type" content="website">
    <meta property="og:url" content="https://tannerdolby.com">
    <meta property="og:locale" content="en_US">
    <meta property="og:title" content="Eleventy Plugin Meta Generator">
    <meta property="og:description" content="An eleventy shortcode for generating meta tags.">
    <meta property="og:image" content="https://tannerdolby.com/images/arch-spiral-large.jpg">
    <meta property="og:image:alt" content="Archimedean Spiral">
    <!-- Twitter -->
    <meta name="twitter:card" content="summary_large_image">
    <meta name="twitter:site" content="@tannerdolby">
    <meta name="twitter:creator" content="@tannerdolby">
    <meta name="twitter:url" content="https://tannerdolby.com">
    <meta name="twitter:title" content="Eleventy Plugin Meta Generator">
    <meta name="twitter:description" content="An eleventy shortcode for generating meta tags.">
    <meta name="twitter:image" content="https://tannerdolby.com/images/arch-spiral-large.jpg">
    <meta name="twitter:image:alt" content="Archimedean Spiral">
    <link rel="canonical" href="https://tannerdolby.com">
    <meta name="custom-tag" content="foo">
    <link rel="stylesheet" href="style.css">
    <link rel="stylesheet" href="design.css">
    <style>h1 { color: #f06; }</style>
    <script src="foo.js"></script>
    <script src="bar.js" async></script>
    <script>console.log('hello, world');</script>
</head>

Custom Usage

For baseline social share functionality, providing arguments shown in the example usage above is recommended. If you want to add more tags not listed in the example, have a look at the plugin docs. You might only need a few <meta> tags instead of the whole set, simply provide the arguments you need and the ones not included won't generate <meta> tags.

Template variables can be used as arguments in Nunjucks and Liquid without the curly braces or quotes like title=page.url. See the metagen docs for more details on plugin usage.

Use Your Template Data

To make your metadata dynamic, you can use template data as arguments to the shortcode, without quotes or braces:

---
title: Some title
desc: Some description
metadata:
  title: Some other title
  desc: Some other description
url: https://tannerdolby.com
image: https://tannerdolby.com/images/arch-spiral-large.jpg
alt: Archimedean spiral
type: summary_large_image 
twitter: tannerdolby
name: Tanner Dolby
---
{% metagen
    title=title or metadata.title,
    desc=desc or metadata.desc,
    url=url + page.url,
    img=image,
    img_alt=alt,
    twitter_card_type=type,
    twitter_handle=twitter,
    name=name
%}

Shorthand syntax:

---
metadata:
  title: foo bar
  desc: some desc
  url: https://tannerdolby.com
  ...
---
{% metagen metadata %}

Meta Tag Reference

Contributing

If you notice an issue or there is a <meta> tag that you need generated which isn't supported, feel free to open an issue.

  1. Fork this repo
  2. Clone git clone [email protected]:tannerdolby/eleventy-plugin-metagen.git
  3. Install dependencies npm install
  4. Build npm run build
  5. Serve locally npm run dev

Other Meta tag generators

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].