1.0.13 • Published 6 years ago
defectiveseo v1.0.13
Defective SEO
Node module that takes in HTML file and a couple of HTML rules returns defects found in the HTML file. Can work for one HTML file or for multiple html file in a directory.
- Takes file from a filepath
- All defective SEO information is printed out on console.
Requirement
- NPM v5 or above
- Node v8 or above
Install
npm install defectiveseo
Usage
const defectiveseo = require('defectiveseo');
or
import defectiveseo from 'defectiveseo';
// defectiveseo( rules : {}, file/directory path );
defectiveseo({
img: 'alt',
a: 'rel',
head: {
title: true,
meta: ["description", "robots", "keywords"],
},
strong: 2,
h1: 100,
},
"test.html");
// this can be a sinle file or a directory as well
SEO Rules
Types of rules
1. <tag> : has attribute rule
2. In head
a. title tag present
b. meta tag has name = [a,b,c,..]
c. ..
..
3. <tag> :limit check limit rule
To check if in the HTML document there are any tags without a certain attribute :
<tag> : '<attribute>'
To check for tags inside head :
head :{
// Check if any HTML file header doesn't have a particular tag
<tag> : true
// Check if the <tag> in header doesn't have one of the name attirbute specified
<tag> : ['optionA', 'optionB', ., ., . ] // name attribute
}
To check if there are more than a certain number of a particular tag add :
<tag> : limit
Assumptions
- Valid HTML file and file/subdirectory path
- For meta tag in head only checking for the attribute 'name'
- Correct rule, one of the three types stated.
- All tags in the rule in lowercase
Testing
Using npm run test
test the package.