SEO
Automatically check SEO basic issues
Options
- output boolean string function
Customize the report output
Default:false- query string
A query to filter the pages to validate
- options object
Options for SEO validation
- commonWords object
Common words to check against
- title object boolean
Rules for title validation
Default:{ maxCommonWords: 45, max: 80, unit: "grapheme" }- h1 object boolean
Rules for H1 validation
Default:{ maxCommonWords: 45, max: 80, unit: "grapheme" }- headingsOrder boolean
Validate that headings are in a proper order
Default:true- duplicateTitles boolean
Check that page titles are not duplicated
Default:true- duplicateDescription boolean
Check that page descriptions are not duplicated
Default:true- description object boolean
Rules for description validation
Default:{ maxCommonWords: 55, min: 1, max: 2, unit: "sentence" }- url object boolean
Rules for URL validation
- imgAlt object boolean
Rules for image alt text validation
Default:{ min: 2, max: 1500, unit: "character" }- imgTitle object boolean
Rules for image title text validation
- body object boolean
Rules for body content validation
Default:{ maxCommonWords: 42, min: 1500, max: 30000, unit: "word" }
Description
Plugin to check the SEO basics (titles, descriptions, alt text in images, etc) and other not very common checks like common words percentage. It creates a new tab in the debug bar with the detected issues.
Installation
Import this plugin in your _config.ts file to use it:
import lume from "lume/mod.ts";
import seo from "lume/plugins/seo.ts";
const site = lume();
site.use(seo(/* Options */));
export default site;
Output
The report is visible in the debug bar but you can use the output option to export the list of broken links to a JSON file:
site.use(seo({
output: "_seo-issues.json",
}));
Or use a function for a custom output:
site.use(seo({
output: (reports) => {
if (!reports.size) {
console.log("No SEO errors found");
} else {
console.log(`${reports.size} pages found with SEO errors`);
}
},
}));
The reports argument is of type Map<string, ErrorMessage[]>: the map keys are the pages with SEO errors, and ErrorMessage[] contains the errors found in the page.