npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@amilochau/seo-webpack-plugin

v0.1.4

Published

Webpack plugin to manage SEO files (sitemap, robots.txt) via configuration

Downloads

1

Readme

@amilochau/seo-webpack-plugin

Introduction

@amilochau/seo-webpack-plugin exposes a Webpack plugin to generate SEO files:

  • the robots.txt file lets crawler know which page they should visit, and references sitemap files
  • the sitemap.xml file (eventually split in multiple files) lets crawler know which pages they should index, with their references with multiple languages

Integration

To integrate the @amilochau/seo-webpack-plugin package, you must follow these three steps.

  1. Install the npm package

Run the following command to install the npm package:

npm install --save-dev @amilochau/seo-webpack-plugin
  1. Register the plugin

In your webpack configuration, create a new instance of the SeoWebpackPlugin:

webpack.config.js

const SeoWebpackPlugin = require('seo-webpack-plugin').default

module.exports = {
  plugins: [new SeoWebpackPlugin()]
}
  1. Configure your SEO

Use your package.json file to configure your SEO for the plugin, with a dedicated section named seo:

package.json

{
  "name": "XXX",
  "version": "1.0.0",
  "seo": {
    "host": "https://example.com",
    "policies": [
      { "userAgent": "*", "allow": "/" }
    ],
    "pages": [
      {
        "relativeUrl": "/",
        "changeFrequency": "daily",
        "priority": 0.6
      }
    ],
    "languages": [
      { "lang": "en", "relativePrefixUrl": "/en" },
      { "lang": "fr", "relativePrefixUrl": "/fr" }
    ]
  }
}

Result

The two following files are generated by the plugin in the assets output folder, during the build of your project.

robots.txt

User-agent: *
Allow: /
Sitemap: https://example.com/sitemap.xml

This robots.txt file allow all crawler to navigate on every page, and links the generated sitemap.xml file.

sitemap.xml

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">
    <url>
        <loc>https://example.com/en</loc>
        <lastmod>2022-01-01T00:00:00.000Z</lastmod>
        <changefreq>daily</changefreq>
        <priority>0.6</priority>
        <xhtml:link rel="alternate" hreflang="en" href="https://example.com/en" />
        <xhtml:link rel="alternate" hreflang="fr" href="https://example.com/fr" />
    </url>
    <url>
        <loc>https://example.com/fr</loc>
        <lastmod>2022-01-01T00:00:00.000Z</lastmod>
        <changefreq>daily</changefreq>
        <priority>0.6</priority>
        <xhtml:link rel="alternate" hreflang="en" href="https://example.com/en" />
        <xhtml:link rel="alternate" hreflang="fr" href="https://example.com/fr" />
    </url>
</urlset>

This sitemap.xml file indicates that two pages (https://example.com/en and https://example.com/fr) should be indexed by the crawlers, and their two pages are linked as languages-connected pages.

Options

More options are available for the plugin, and will be documented soon :)


Contribute

Feel free to push your code if you agree with publishing under the MIT license.