Skip to content
This repository has been archived by the owner on Oct 21, 2023. It is now read-only.

Latest commit

 

History

History
46 lines (32 loc) · 1.04 KB

README.md

File metadata and controls

46 lines (32 loc) · 1.04 KB

waigo-plugin-url-slash-sel

This waigo plugin provides:

urlSlashSeo

This middleware enhances your SEO by auto-redirecting the client to the correct version of a URL with or without an ending slash when the incorrect version is accessed.

If using this middleware then ensure you write your routes according to your chosen rule, i.e. with or without ending slashes.

Note that this middleware only intercepts GET and HEAD requests.

Installation

$ npm install waigo-plugin-url-slash-seo

Example

In your configuration file enable it as common middleware:

config.middleware.order = [
  'errorHandler',
  'staticResources',
  'urlSlashSeo',  // check now, before any more work is done
  'sessions',
  'outputFormats'
];

config.middleware.options.urlSlashSeo = {
  /* If false then correct URLs don't have a trailing slash. If true they do. */
  withSlash: false,
  /* If true then redirect with status code 301, else use 302 */
  permRedirect: true
};

License

MIT - see LICENSE.md