Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
js-seo-ingector
Advanced tools
A Javascript command to automatically modify the main html file (like index.html) to add the provided SEO meta tags and more. Designed for Create React App.
A Javascript command to automatically modify the main html file (like index.html) to add the provided SEO meta tags and more. Designed for Create React App. For example you can use it to add on the build time the following meta tags: title, description, open graph, twitter, icons and more.
npx js-seo-ingector
Example with --pretty:
Before:
After:
In a standard CRA project, we have to add seo html tags into the production build index.html file.
To make it automatic, we can edit the package.json file at the build script:
from this:
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
to this:
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build && npx js-seo-ingector",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
And then we have to create a seo.json file in the same directory as the package.json file.
Example json file (seo.json):
{
"title": "Example Title",
"description": "Example Description",
"keywords": "Example Keywords",
"author": "Example Author",
"openGraph": {
"url": "https://example.com",
"title": "Example Title",
"description": "Example Description",
"image": "https://example.com/image.jpg",
"site_name": "Example Site Name",
"type": "website",
"locale": "it_IT"
},
"twitter": {
"image": "https://example.com/image.jpg",
"url": "https://example.com",
"card": "summary_large_image",
"title": "Example Title",
"description": "Example Description"
},
"favicon": null,
"manifest": null,
"icons": [{
"src": "https://example.com/icon-192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "https://example.com/icon-512.png",
"sizes": "512x512",
"type": "image/png"
}
]
}
Then we can run the build script:
npn run build
and the seo tags will be injected into the ./build/index.html file.
type: string required: true result:
<title>Example Title</title>
<meta name="title" content="Example Title">
type: string required: true result:
<meta name="description" content="Example Description">
type: string required: true result:
<meta name="keywords" content="Example Keywords">
type: string required: true result:
<meta name="author" content="Example Author">
type: object required: false props:
result:
<meta property="og:url" content="https://example.com">
<meta property="og:title" content="Example Title">
<meta property="og:description" content="Example Description">
<meta property="og:image" content="https://example.com/image.jpg">
<meta property="og:site_name" content="Example Site Name">
<meta property="og:type" content="website">
<meta property="og:locale" content="it_IT">
type: object required: false props:
result:
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:url" content="https://example.com">
<meta name="twitter:title" content="Example Title">
<meta name="twitter:description" content="Example Description">
<meta name="twitter:image" content="https://example.com/image.jpg">
type: string required: false result:
<link rel="icon" href="./favicon.ico" />
type: string required: false result:
<link rel="manifest" href="./manifest.json" />
type: array required: false content: type: object props:
result:
<link rel="icon" sizes="192x192" href="./icon-192.png" />
<link rel="icon" sizes="512x512" href="./icon-512.png" />
description: In this field you can put what you want type: array required: false content: type: object props:
result (example):
<meta name="custom" content="custom-value">
or in case of this example:
"custom": [{
"tag": "script",
"children": "if (window.location.hostname === 'example.com') { window.location.hostname = 'example.com'; }"
}]
<script>
if (window.location.hostname === 'example.com') { window.location.hostname = 'example.com'; }
</script>
This tool does not check if the tags are already present in the html file. It will inject the tags in the html file before the closing head tag.
This tool is licensed under the MIT license. Author: Elia Lazzari
FAQs
A Javascript command to automatically modify the main html file (like index.html) to add the provided SEO meta tags and more. Designed for Create React App.
The npm package js-seo-ingector receives a total of 0 weekly downloads. As such, js-seo-ingector popularity was classified as not popular.
We found that js-seo-ingector demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.