Quickstart
This guide lints a built site, reads the report, and adds a config file. It takes a few minutes.
1. Build your site
seolint reads the HTML that your site generator writes. Build your site first, so the output folder exists:
npm run build
2. Lint the output folder
Run seolint on the output folder, such as public or dist, and give it the URL of your site:
npx seolint public --host https://example.com
The --host tells internal links from external ones, and gives each page its URL, such as https://example.com/about/. Without it, only relative links count as internal.
3. Read the report
seolint prints each page that has problems, with one line for each problem:
FAIL public/about/index.html
✘ A "meta[name=description]" must exist description.exists
6:2 ⚠ Must not have less than 10 characters title.content.length
21:52 ⚠ Must describe the target, not "click here" link.text.vague
FAIL Reported 1 error and 2 warnings!
Each line has four columns:
- The line and column of the element. A problem with no element, such as a missing tag, has no position.
✘for an error, or⚠for a warning.- The message.
- The rule name. Each rule has a page in the rules reference, such as
title.content.length.
seolint exits with 1 when there is at least one error. Warnings do not fail the run.
4. Add a config file
Create seolint.config.ts in your project folder, so you do not need the options each time:
import * as config from "seolint/config";
export default config.define({
host: "https://example.com",
inputs: ["public"],
rules: {
"title.content.length": { max: 70 },
"link.text.vague": false,
},
});
Now run seolint with no options:
npx seolint
define() checks the rule names and options as you type. See Configuration for every field.
5. Run it in CI
Add seolint after the build step of your CI. With --format ci, each problem shows on its file and line in the pull request:
- run: npm run build
- run: npx seolint --format ci
See CI for a complete workflow.
Next steps
- Adopt seolint on a large site with the
essentialspreset, then turn on more rules. - Write your own rules with plugins.
- Lint from your own scripts with the API.