🌊 aitch-seo
🌏 SEO toolkit
aitch-seo
helps you with loading the HTML document and evaluating if the HTML document has followed the rules you specified.
This module supports:
- Fetching the HTML document from the location specified by URL or
ReadableStream
. - Validating the fetched document with the customised rules.
- Exporting the evaluation results with the
WritableStream
provided, e.g., MemoryStream, FileStream, and Console etc.
This module uses cheerio
to construct the DOM for you.
📋 Install
npm install --save-dev aitch-seo
📋 Try it out
const AWithNoRelRule = ;const ImgWithNoAltRule = ;const HeadRule = ;const TooStrongRule = ;const TooManyH1sRule = ;const SEO = ; var rules = ImgWithNoAltRule //1 AWithNoRelRule //2 TooStrongRule//3 TooManyH1sRule //4 HeadRule //5; var test_writing_file = __dirname + '/output.txt';var test_file = 'https://www.lian-car.com';var result = SEO; result;
The content of output.txt
:
There is no <IMG> tag in this HTML document without "alt" attribute.
There is no <A> tag in this HTML document without "rel" attribute.
There is no <STRONG> tag in this HTML document.
There is 1 <H1> tag in thie HTML document
This HTML does have <TITLE> tag.
This HTML does have <META> tag with "name=descriptions".
This HTML does have <META> tag with "name=keywords".
📋 Test the source
Make sure you have installed mocha
:
$> npm install --save-dev mocha
#or you just want to party:
$> npm i -g mocha
Goto clone this project from GitHub page:
$> git clone git@github.com:aitch0083/aitch-seo.git
$> cd aitch-seo
$> npm install
Then you can run the test:
$> npm run test
📋 What you get:
//get the HTML document from the location specified by URLSEO{} //get the HTML document from the location //specified by "target", the file name stringSEO{} //get the HTML document from the location //specified by "target", the ReadableStream objectSEO{} //output the validation results to the location // specified by WritableStream, and join the content with "delimiter" specifiedSEO{} //output the validation results to the location //specified by "target", the file name stringSEO{} //you figure it out, it's funSEO{} //validate the HTML content with the rules providedSEO{}
📋 Usage:
Including the SEO
object:
var SEO = ;
Fetching by assigning the URL
:
var SEO = ;var url = 'https://www.lian-car.com/';var result = SEO; result;
Fetching by assigning the file name:
var SEO = ;var test_file = '/somewhere_out_there/random_html_document.html';var result = SEO;result;
Fetching and validating:
//Import your rulesconst AWithNoRelRule = ;const ImgWithNoAltRule = ;const HeadRule = ; const rules = ImgWithNoAltRule AWithNoRelRule HeadRule; var test_file = '/somewhere_out_there/random_html_document.html';var result = SEO; result; //you will get the following message if succeed://There are 2 <IMG> tags without "alt" attributes.//There are 11 <A> tags without "rel" attributes.//This HTML does have <TITLE> tag.
Wrting to a place you like:
var test_writing_file = '/somewhere_awesome/output.txt';var test_file = '/somewhere_out_there/random_html_document.html';var result = SEO; result;
Wrting to any WritableStream:
const ms = ;//fancy~~~ var test_file = '/somewhere_out_there/random_html_document.html';var result = SEO;var writer = ; result;
More usages, please refer to test/test.js
.
📋 Customise your own Rule
Since all the rules derive from rules/Rule
, you can use any rule in the rules
folder as the template:
#file name: rules/MyOwnRulejs'use strict' const _ = ;const Rule = ; const MyOwnRule = _; moduleexports = MyOwnRule; #Import this rulevar MR = ;var rules = MR; var test_writing_file = '/somewhere_awesome/output.txt';var test_file = '/somewhere_out_there/random_html_document.html';var result = SEO; result;
You can change the order of the rules by defining your own rules
array:
const AWithNoRelRule = ;const ImgWithNoAltRule = ;const HeadRule = ;const TooStrongRule = ;const TooManyH1sRule = ; var rules = ImgWithNoAltRule //1 AWithNoRelRule //2 TooStrongRule//3 TooManyH1sRule //4 HeadRule //5;
Have fun~~