Eleventy: mention a recommended meta generator tag

Created on 29 May 2020  路  14Comments  路  Source: 11ty/eleventy

Automated website stack detection tools like wappalyzer currently don't recognise 11ty. The "official" way to recognise the static generator is by <meta generator="x"> tag.

  1. Let's agree on the default, "official" 11ty meta generator tag's value. I propose it to be in format:
<meta name="generator" content="11ty v0.11.0" />

value format being: 11ty + space + v + (semver in x.y.z format)

  1. Once agreed, let's mention this in the documentation and encourage users to put this tag in their markup. Currently we don't have a machine-readable way to tell the world it's built on 11ty.
documentation

Most helpful comment

I'm now using <meta name="generator" content="Eleventy v0.11.1" /> as Zach told us in #1283 that Eleventy is the "software package specifically".

All 14 comments

There also is the plugin that @Ryuno-Ki created: https://github.com/Ryuno-Ki/eleventy-plugin-meta-generator. I haven't used it but agree with its spelling out "Eleventy" rather than just "11ty," so as to cover all search possibilities.

On a separate but related subject: would be nice if the version number were exposed in the Eleventy API for just this purpose, for easy insertion in one's <head> partial along the lines of what's being suggested in this issue.

I was about to update my plugin for v0.11.
If @zachleat agrees, I can update its value, no problem.

I just came up with something to make it somehow discoverable.
I pull the number from the package.json of the installed package.

I was about to update my plugin for v0.11.
If @zachleat agrees, I can update its value, no problem.

I just came up with _something_ to make it somehow discoverable.
I pull the number from the package.json of the installed package.

Any chance you could add some .11ty.js-friendly instructions in the README? 馃槃

Edit: In the meantime, I added the following to my head.js partial to provide automatic version info:

const jsonInfo = require(`../../../../package.json`)
var eleventyVersion = jsonInfo.devDependencies['@11ty/eleventy']
if (eleventyVersion.charAt(0) == "^") {
  eleventyVersion = eleventyVersion.substring(1)
}

module.exports = function(eleventyConfig) {

  eleventyConfig.addShortcode('headTag', function(data) {

    return `
    <head>
    <meta name="generator" content="Eleventy - 11ty - https://11ty.dev - Version ${eleventyVersion}" />

Sure. Fill an issue at https://github.com/Ryuno-Ki/eleventy-plugin-meta-generator/issues/new so I can keep a reference to it, please.

Sure. Fill an issue at https://github.com/Ryuno-Ki/eleventy-plugin-meta-generator/issues/new so I can keep a reference to it, please.

Done. Thanks!

Edit: In the meantime, I added the following to my head.js partial to provide automatic version info:

const jsonInfo = require(`../../../../package.json`)
var eleventyVersion = jsonInfo.devDependencies['@11ty/eleventy']
if (eleventyVersion.charAt(0) == "^") {
  eleventyVersion = eleventyVersion.substring(1)
}

module.exports = function(eleventyConfig) {

  eleventyConfig.addShortcode('headTag', function(data) {

    return `
    <head>
    <meta name="generator" content="Eleventy - 11ty - https://11ty.dev - Version ${eleventyVersion}" />

@brycewray You can require 11ty's version directly with require(@11ty/eleventy/package.json).version.
No version parsing needed 馃槂

module.exports = function (config) {
  config.addShortcode(`addGenerator`, () => {
    return `<meta name="generator" content="Eleventy - 11ty - https://11ty.dev - v${require(`@11ty/eleventy/package.json`).version}" />`;
  })
}

@brycewray You can require 11ty's version directly with require(@11ty/eleventy/package.json).version.
No version parsing needed 馃槂

[Slapping own forehead] Ah. Thanks, @denisbrodbeck !

Related to #1283

I'm now using <meta name="generator" content="Eleventy v0.11.1" /> as Zach told us in #1283 that Eleventy is the "software package specifically".

@nhoizey I use that format as well.

Note that if you use the latest (unstable) version of Eleventy from GitHub (ie. with npm install github:11ty/eleventy), you can write v1.0.0-beta.0+sha:<commit-hash> as per the semver spec. Not sure if it's necessary, although you would at least want to distinguish between GitHub and NPM.

@binyamin you're right, if we use the optional version number, it should be accurate! 馃憤

Proving once again that it does pay to look through the documentation (and I鈥檓 talking to myself on that one 馃槃 ), here is a method that works just fine in Nunjucks templates and uses Eleventy鈥檚 built-in pkg data value:

<!-- from `head.njk` -->
{% set eleventyVersion = pkg.devDependencies['@11ty/eleventy'] | replace("^", "") %}

  <head>
    <meta name="generator" content="Eleventy v{{ eleventyVersion }}" />

I suspect it would be equally useful, with obvious alterations, in other templating options. Of course, you must change that pkg part to pkg.dependencies if you have Eleventy just plain installed and not --save-dev installed. 馃槈

Note that if you use the latest (unstable) version of Eleventy from GitHub (ie. with npm install github:11ty/eleventy), you can write v1.0.0-beta.0+sha:<commit-hash> as per the semver spec. Not sure if it's necessary, although you would at least want to distinguish between GitHub and NPM.

@binyamin Could you also advise where to find docs (such as they may be) for the beta? Your post here is the first I鈥檝e seen that gives the npm command for obtaining it. Thanks.

@brycewray I don't know that they exist, to be honest.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aaronstezycki picture aaronstezycki  路  3Comments

zac-heisey picture zac-heisey  路  3Comments

nilsmielke picture nilsmielke  路  4Comments

DirtyF picture DirtyF  路  3Comments

smaimon picture smaimon  路  3Comments