{"id":28092461,"url":"https://github.com/jafaircl/gatsby-plugin-amp","last_synced_at":"2025-10-13T07:06:58.983Z","repository":{"id":33582751,"uuid":"156762089","full_name":"jafaircl/gatsby-plugin-amp","owner":"jafaircl","description":"Gatsby plugin for creating AMP pages","archived":false,"fork":false,"pushed_at":"2023-01-04T17:32:29.000Z","size":213,"stargazers_count":34,"open_issues_count":19,"forks_count":28,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-11T05:12:26.116Z","etag":null,"topics":["amp","amp-html","gatsby"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jafaircl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-08T20:03:43.000Z","updated_at":"2023-05-12T16:52:53.000Z","dependencies_parsed_at":"2023-01-15T01:31:28.411Z","dependency_job_id":null,"html_url":"https://github.com/jafaircl/gatsby-plugin-amp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jafaircl/gatsby-plugin-amp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jafaircl%2Fgatsby-plugin-amp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jafaircl%2Fgatsby-plugin-amp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jafaircl%2Fgatsby-plugin-amp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jafaircl%2Fgatsby-plugin-amp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jafaircl","download_url":"https://codeload.github.com/jafaircl/gatsby-plugin-amp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jafaircl%2Fgatsby-plugin-amp/sbom","scorecard":{"id":501977,"data":{"date":"2025-08-11","repo":{"name":"github.com/jafaircl/gatsby-plugin-amp","commit":"520fb1ed647d650b9ba9e7bb48eb1447419e1cbf"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Code-Review","score":3,"reason":"Found 7/18 approved changesets -- score normalized to 3","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 21 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"42 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-6chw-6frg-f759","Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-w8qv-6jwh-64r5","Warn: Project is vulnerable to: GHSA-c6rq-rjc2-86v2","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-8r6j-v8pm-fqw3","Warn: Project is vulnerable to: MAL-2023-462","Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37","Warn: Project is vulnerable to: GHSA-896r-f27r-55mw","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-6c8f-qphg-qjgp","Warn: Project is vulnerable to: GHSA-jf85-cpcp-j695","Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-fhjf-83wg-r2j9","Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9","Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp","Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-4g88-fppr-53pp","Warn: Project is vulnerable to: GHSA-4jqc-8m5r-9rpr","Warn: Project is vulnerable to: GHSA-j44m-qm6p-hp7m","Warn: Project is vulnerable to: GHSA-3jfq-g458-7qm9","Warn: Project is vulnerable to: GHSA-r628-mhmh-qjhw","Warn: Project is vulnerable to: GHSA-9r2w-394v-53qc","Warn: Project is vulnerable to: GHSA-5955-9wpr-37jh","Warn: Project is vulnerable to: GHSA-qq89-hq3f-393p","Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3","Warn: Project is vulnerable to: GHSA-6fc8-4gx4-v693","Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-19T22:09:23.956Z","repository_id":33582751,"created_at":"2025-08-19T22:09:23.956Z","updated_at":"2025-08-19T22:09:23.956Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279006637,"owners_count":26084150,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-11T02:00:06.511Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["amp","amp-html","gatsby"],"created_at":"2025-05-13T13:16:59.334Z","updated_at":"2025-10-13T07:06:58.955Z","avatar_url":"https://github.com/jafaircl.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gatsby-plugin-amp\n\nFormats AMP-specific pages by removing javascript, combining styles and adding boilerplate. Read more about AMP (Accelerated Mobile Pages) [here](https://amp.dev/).\n\n## Install\n\n`npm install --save gatsby-plugin-amp`\n\n## How to use\n\nCreate AMP-specific templates. Assume you have the following blog post template in `post.js`\n\n```javascript\nimport React from 'react'\nimport Img from 'gatsby-image'\nimport Layout from '../../components/layout'\n\nexport default ({ data }) =\u003e (\n  \u003cLayout\u003e\n    \u003cImg fluid={data.image.fluid} /\u003e\n    \u003ch1\u003eREGULAR PAGE\u003c/h1\u003e\n    \u003cp\u003eregular page content\u003c/p\u003e\n  \u003c/Layout\u003e\n)\n```\n\nCreate an AMP template `post.amp.js`\n\n```javascript\nimport React from 'react'\nimport Layout from '../../components/layout'\n\nexport default ({ data }) =\u003e (\n  \u003cLayout\u003e\n    \u003camp-img src-set={data.image.srcSet} src={data.image.src} width={data.image.width} height={data.image.height} alt={data.image.altText} layout=\"responsive\" /\u003e\n    \u003ch1\u003eAMP PAGE\u003c/h1\u003e\n    \u003cp\u003eamp page content\u003c/p\u003e\n  \u003c/Layout\u003e\n)\n```\n\nTo assist with situations like images in markdown or other externally created HTML, the plugin will attempt to turn `img` tags to `amp-img` or `amp-anim`. While creating posts in your `gatsby-node.js` file, create an additional page in the `/amp/` directory using the AMP template you just made\n\n```javascript\n_.each(posts, (post, index) =\u003e {\n  const previous = index === posts.length - 1 ? null : posts[index + 1].node;\n  const next = index === 0 ? null : posts[index - 1].node;\n\n  createPage({\n    path: post.node.fields.slug,\n    component: path.resolve('./src/templates/post.js'),\n    context: {\n      slug: post.node.fields.slug,\n      previous,\n      next,\n    },\n  })\n\n  createPage({\n    path: `${post.node.fields.slug}/amp`,\n    component: path.resolve('./src/templates/post.amp.js'),\n    context: {\n      slug: post.node.fields.slug,\n      previous,\n      next,\n    },\n  })\n})\n```\n\nWhen you build your site, you should now have pages at `/my-awesome-post/index.html` and `/my-awesome-post/amp/index.html`\n\nAdd the plugin to the plugins array in your `gatsby-config.js`\n\n```javascript\n{\n  resolve: `gatsby-plugin-amp`,\n  options: {\n    analytics: {\n      type: 'gtag',\n      dataCredentials: 'include',\n      config: {\n        vars: {\n          gtag_id: \u003cGA_TRACKING_ID\u003e,\n          config: {\n            \u003cGA_TRACKING_ID\u003e: {\n              page_location: '{{pathname}}'\n            },\n          },\n        },\n      },\n    },\n    canonicalBaseUrl: 'http://www.example.com/',\n    components: ['amp-form'],\n    excludedPaths: ['/404*', '/'],\n    pathIdentifier: '/amp',\n    relAmpHtmlPattern: '{{canonicalBaseUrl}}{{pathname}}{{pathIdentifier}}',\n    useAmpClientIdApi: true,\n  },\n},\n```\n\nWhen your site builds, your page in the `/amp` directory should now be a valid AMP page\n\n## Options\n\n**analytics** `{Object}`\nIf you want to include any `amp-analytics` tags, set that configuration here.\n\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;**type** `{String}`\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;Your analytics type. See the list of available vendors [here](https://www.ampproject.org/docs/analytics/analytics-vendors).\n\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;**dataCredentials** `{String}`\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;You value for the `data-credentials` attribute. Omit to remove the attribute.\n\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;**config** `{Object | String}`\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;This can be either an object containing your analytics configuration or a url to your analytics configuration. If you use Google Analytics gtag, your cofiguration might look like this:\n\n```javascript\nvars: {\n  gtag_id: \u003cGA_TRACKING_ID\u003e,\n  config: {\n    \u003cGA_TRACKING_ID\u003e: {\n      page_location: '{{pathname}}'\n    },\n  },\n},\n```\n\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp; If you use a tag manager, your config would simply be a url like `https://www.googletagmanager.com/amp.json?id=GTM-1234567\u0026amp;gtm.url=SOURCE_URL`. You can use double curly braces to interpolate the pathname into a configuration value e.g. `page_location: '{{pathname}}'`. See [here](https://www.ampproject.org/docs/reference/components/amp-analytics) to learn more about `amp-analytics` configurations.\n\n**canonicalBaseUrl** `{String}`\nThe base URL for your site. This will be used to create a `rel=\"canonical\"` link in your amp template and `rel=\"amphtml\"` link in your base page.\n\n**components** `{Array\u003cString | Object{name\u003cString\u003e, version\u003cString\u003e}\u003e}`\nThe components you will need for your AMP templates. Read more about the available components [here](https://www.ampproject.org/docs/reference/components).\n\n**excludedPaths**`{Array\u003cString\u003e}`\nBy default, this plugin will create `rel=\"amphtml\"` links in all pages. If there are pages you would like to not have those links, include them here. You may use glob patterns in your strings (e.g. `/admin/*`). *this may go away if a way can be found to programatically exclude pages based on whether or not they have an AMP equivalent. But for now, this will work*\n\n**includedPaths**`{Array\u003cString\u003e}`\nBy default, this plugin will create `rel=\"amphtml\"` links in all pages. If, you would instead like to whitelist pages, include them here. You may use glob patterns in your strings (e.g. `/blog/*`). *this may go away if a way can be found to programatically exclude pages based on whether or not they have an AMP equivalent. But for now, this will work*\n\n**pathIdentifier** `{String}`\nThe url segment which identifies AMP pages. If your regular page is at `http://www.example.com/blog/my-awesome-post` and your AMP page is at `http://www.example.com/blog/my-awesome-post/amp/`, your pathIdentifier should be `/amp/`\n\n**relAmpHtmlPattern** `{String}`\nThe url pattern for your `rel=\"amphtml\"` links. If your AMP pages follow the pattern `http://www.example.com/my-awesome-post/amp/`, the value for this should be `{{canonicalBaseUrl}}{{pathname}}{{pathIdentifier}}`.\n\n**relCanonicalPattern** `{String}`\nThe url pattern for your `rel=\"canonical\"` links. The default value is `{{canonicalBaseUrl}}{{pathname}}`.\n\n**useAmpClientIdApi** `{Boolean}`\nIf you are using a Client ID for Google Analytics, you can use the [Google AMP Client ID](https://support.google.com/analytics/answer/7486764) to determine if events belong to the same user when they visit your site on AMP and non-AMP pages. Set this to `true` if you would like to include the necessary meta tag in your AMP pages. You can read more about this concept [here](https://www.simoahava.com/analytics/accelerated-mobile-pages-via-google-tag-manager/#2-1-client-id)\n\n## Caveats\n\nThe standard HTML template that Gatsby uses will cause a validation error. This is because it is missing `minimum-scale=1` in the meta viewport tag. You can create a `html.js` template file under your `src/` directory in order to override the default Gatsby one available [here](https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby/cache-dir/default-html.js). Alternatively, you can simply clone it by runnig the shell command below at the root of your project. Read more [here](https://www.gatsbyjs.org/docs/custom-html/) on customizing your `html.js`.\n\n```shell\ncp .cache/default-html.js src/html.js\n```\n\nDon't forget to update the meta viewport tag value from its initial to the required AMP value.\n\n```html\n\u003c!-- Initial viewport meta tag --\u003e\n\u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1, shrink-to-fit=no\" /\u003e\n\u003c!-- Replacement viewport meta tag (for AMP validity) --\u003e\n\u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1, minimum-scale=1, shrink-to-fit=no\" /\u003e\n```\n\n## Automatically Converted Elements\n\nWhile it is preferable to create AMP-specific templates, there may be situations where an image, iframe or some other element can't be modified. To cover these cases, the plugin will attempt to convert certain tags to their AMP equivalent.\n\n| HTML Tag       | AMP Tag           | Status                     | Issue |\n|----------------|-------------------|----------------------------|-------|\n| `img`          | `amp-img`         | Completed                  |       |\n| `img (.gif)`   | `amp-anim`        | Completed                  |       |\n| `iframe`       | `amp-iframe`      | Completed                  |       |\n| `audio`        | `amp-audio`       | Planned, Not Started       |       |\n| `video`        | `amp-video`       | Planned, Not Started       |       |\n| YouTube        | `amp-youtube`     | Completed                  |       |\n| Facebook       | `amp-facebook`    | Planned, Not Started       |       |\n| Instagram      | `amp-instagram`   | Planned, Not Started       |       |\n| Twitter        | `amp-twitter`     | Completed                  |       |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjafaircl%2Fgatsby-plugin-amp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjafaircl%2Fgatsby-plugin-amp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjafaircl%2Fgatsby-plugin-amp/lists"}