SEO
Automatically check SEO basic issues
Options
- output boolean string function
- Default:
false - query string
- options object
- Default:
{ commonWords: Set(156) { "the", "a", "an", "and", "but", "or", "nor", "for", "so", "yet", "to", "in", "at", "on", "by", "with", "of", "from", "as", "is", "are", "was", "were", "be", "been", "have", "has", "had", "do", "does", "did", "will", "would", "can", "could", "should", "may", "might", "must", "i", "you", "he", "she", "it", "we", "they", "me", "him", "her", "us", "them", "my", "your", "his", "hers", "its", "our", "their", "this", "that", "these", "those", "one", "two", "three", "four", "five", "first", "last", "new", "good", "bad", "man", "woman", "child", "time", "year", "day", "night", "now", "then", "very", "much", "many", "some", "all", "any", "most", "other", "more", "out", "up", "down", "over", "under", "again", "also", "however", "therefore", "because", ... 56 more items }, title: { maxCommonWords: 45, max: 80, unit: "grapheme" }, h1: { maxCommonWords: 45, max: 80, unit: "grapheme" }, description: { maxCommonWords: 55, min: 1, max: 2, unit: "sentence" }, headingsOrder: true, duplicateTitles: true, duplicateDescription: true, imgAlt: { min: 2, max: 1500, unit: "character" }, body: { 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.