{"id":13626474,"url":"https://github.com/maddevsio/seo-analyzer","last_synced_at":"2025-04-09T18:17:30.715Z","repository":{"id":40998151,"uuid":"409446378","full_name":"maddevsio/seo-analyzer","owner":"maddevsio","description":"The library for analyze a HTML file to show all of the SEO defects","archived":false,"fork":false,"pushed_at":"2024-04-18T05:35:51.000Z","size":54463,"stargazers_count":83,"open_issues_count":9,"forks_count":13,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-09T18:17:21.055Z","etag":null,"topics":["angular","html","javascript","node","react","search-engine","seo","vue"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maddevsio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-09-23T04:23:57.000Z","updated_at":"2025-04-07T17:31:46.000Z","dependencies_parsed_at":"2024-10-31T06:02:55.633Z","dependency_job_id":"a2faaeb3-273a-4a35-8ed8-63fa9004ddb4","html_url":"https://github.com/maddevsio/seo-analyzer","commit_stats":{"total_commits":183,"total_committers":6,"mean_commits":30.5,"dds":0.3770491803278688,"last_synced_commit":"8ec76a346224e88a0508033a6494e34e5707aa73"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maddevsio%2Fseo-analyzer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maddevsio%2Fseo-analyzer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maddevsio%2Fseo-analyzer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maddevsio%2Fseo-analyzer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maddevsio","download_url":"https://codeload.github.com/maddevsio/seo-analyzer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248085321,"owners_count":21045139,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["angular","html","javascript","node","react","search-engine","seo","vue"],"created_at":"2024-08-01T21:02:20.016Z","updated_at":"2025-04-09T18:17:30.692Z","avatar_url":"https://github.com/maddevsio.png","language":"TypeScript","funding_links":[],"categories":["Development Utilities","TypeScript","📦 Legacy \u0026 Inactive Projects"],"sub_categories":["SEO"],"readme":"# SEO analyzer — library for searching SEO issues\n\n[![Developed by Mad Devs](https://maddevs.io/badge-dark.svg)](https://maddevs.io?utm_source=github\u0026utm_medium=madboiler) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n![Preview](preview.png)\n\nThe library for analyze a HTML files to show all of the SEO defects.\n\n## Translations of documentation\n\n- English\n- [Russian](./README_RU.md)\n\n## Advantages of this plugin\n\n- Easy setup.\n- Adding custom rules.\n- 6 ready-made rules.\n- Running the seo-analyzer for SSR applications.\n- Running the seo-analyzer for SPA applications.\n- Running the seo-analyzer in pipelines(github, gitlab, ...) or pre-push or anywhere else.\n- Multiple options for outputting the result.\n\n## Why you should use Seo Analyzer\n\n- **Saves time:** will save you from manually searching for seo problems.\n- **Seo Friendly:** will save your project from problems with search engines.\n- **It’s free:** we’re happy to share the results of our work.\n\n## How to use the CLI\n\nTo use the CLI, you must install the package globally.\n\n```sh\nnpm install -g seo-analyzer\n```\n\n### Usage\n\n```sh\nseo-analyzer -h\n```\n\n| Option | Args | Description |\n| --- | --- | --- |\n| -h, --help | null | Show all options. |\n| -v, --version | null | **Display Application Version:** Displays the current version of the application. |\n| -iu, --ignoreUrls | [array] | **Exclude Specific URLs from Analysis:** Excludes certain URLs from analysis to avoid processing unwanted web pages. |\n| -if, --ignoreFiles | [array] | **Exclude Specific Files from Analysis:** Allows excluding certain files from analysis, preventing their processing. |\n| -ifl, --ignoreFolders | [array] | **Exclude Specific Folders from Analysis:** Excludes specified folders from the analysis process, ignoring all files within those folders. |\n| -u, --urls | [array] | **Perform SEO Analysis on Specified URLs:** Conducts SEO analysis for specified URLs, checking their compliance with certain SEO criteria. |\n| -f, --files | [array] | **Perform SEO Analysis on Specified Files:** Performs SEO analysis on specified files, ensuring their adherence to optimization standards and rules. |\n| -fl, --folder | [array] | **Perform SEO Analysis on Specified Folders:** Analyzes all files within specified folders for compliance with SEO rules and recommendations. |\n| -r, --rules | [array] | **Apply Specific SEO Rules for Analysis:** Applies specific SEO rules during analysis, allowing the user to customize the inspection process. By default run all default rules. |\n\n#### Example of using multiple url analysis\n\n```sh\nseo-analyzer -u https://maddevs.io https://maddevs.io/blog\n```\n\n#### Example of using rules\n\n```sh\nseo-analyzer -u https://maddevs.io -r titleLengthRule='{ \"min\": \"500\" }'\n```\n\nUse json format to pass parameters to the rule.\n\n## How to use as github action\n\nTo use SEO analyzer as actions on github, you can create a workflow file in .github/workflows/analyzer.yml with the following content:\n\n```yml\nname: SEO analyzer\n\non: [push]\n\njobs:\n  seo-analyzer:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v4\n      - name: Use Node.js\n        uses: actions/setup-node@v4\n        with:\n          node-version: '20.x'\n      - run: npm i -g seo-analyzer\n      - run: seo-analyzer -u https://maddevs.io\n```\n\nIn the last step, you can specify the url you want to analyse.\n\n## How to use as API\n\nInstall to the project.\n\n```sh\nnpm install -D seo-analyzer\n```\n\n## Usage\n\n### Getting started\n\nSetting up the SEO analyzer is as simple as possible. It will look something like this:\n\n```js\nconst SeoAnalyzer = require('seo-analyzer');\n\nnew SeoAnalyzer()\n  .inputFiles(\u003carray\u003e)\n  .addRule(\u003cfunction\u003e)\n  .addRule(\u003cfunction\u003e)\n  .outputConsole()\n  .run();\n```\n\nNext I will show you some examples.\n\n#### One way: analyze the url list and output the report to the console\n\n```js\nconst SeoAnalyzer = require('seo-analyzer');\n\nnew SeoAnalyzer()\n  .inputUrls(['https://maddevs.io', 'https://maddevs.io/blog'])\n  .addRule('imgTagWithAltAttributeRule')\n  .outputConsole()\n  .run();\n```\n\n#### Two way: file analysis for SPA application and log report to console\n\n```js\nconst SeoAnalyzer = require('seo-analyzer');\n\nnew SeoAnalyzer()\n  .ignoreUrls(['/404', '/login'])\n  .inputSpaFolder('/dist', 'sitemapindex.xml', 3000)\n  .addRule('imgTagWithAltAttributeRule')\n  .outputConsole()\n  .run();\n```\n\n#### Three way: read a list HTML files and log report to console\n\n```js\nconst SeoAnalyzer = require('seo-analyzer');\n\nnew SeoAnalyzer()\n  .inputFiles(['index.html', 'about.html'])\n  .addRule('imgTagWithAltAttributeRule')\n  .outputConsole();\n```\n\n#### Fourth way: read a folders with HTML files and log report to console\n\n```js\nconst SeoAnalyzer = require('seo-analyzer');\n\nnew SeoAnalyzer()\n  .inputFolders(['dist', 'src'])\n  .addRule('imgTagWithAltAttributeRule')\n  .outputConsole()\n  .run();\n```\n\n#### Fifth way: read a folders with HTML files and return json\n\n```js\nconst SeoAnalyzer = require('seo-analyzer');\n\nnew SeoAnalyzer()\n  .inputFolders(['dist', 'src'])\n  .addRule('imgTagWithAltAttributeRule')\n  .outputJson(json =\u003e console.log(json))\n  .run();\n```\n\n#### Sixth way: ignore subfolder \"test\" and 404.html in folder \"src\" and return js object\n\n```js\nconst SeoAnalyzer = require('seo-analyzer');\n\nnew SeoAnalyzer()\n  .ignoreFolders(['src/test'])\n  .ignoreFiles(['src/404.html'])\n  .inputFolders(['dist', 'src'])\n  .addRule('imgTagWithAltAttributeRule')\n  .outputObject(obj =\u003e console.log(obj))\n  .run();\n```\n\n#### Seventh way: Input an HTML string directly and log report to console\n\n```js\nconst SeoAnalyzer = require('seo-analyzer');\n\nnew SeoAnalyzer()\n  .inputHTMLString(\n    '\u003c!DOCTYPE html\u003e\u003chtml\u003e\u003cbody\u003e\u003ch1\u003etitle\u003c/h1\u003e\u003cp\u003econtent\u003c/p\u003e\u003c/body\u003e\u003c/html\u003e'\n  )\n  .addRule('imgTagWithAltAttributeRule')\n  .outputConsole()\n  .run();\n```\n\n## Available methods:\n\n| Method | Params | Description |\n| --- | --- | --- |\n| ignoreFiles | ['dist/about.html'] | This method expects an array of files to ignore before analysis. |\n| ignoreFolders | ['dist/ignore'] | This method expects an array of folders to ignore before analysis. |\n| ignoreUrls | ['/404'] | This method expects an array of urls to ignore before analysis. |\n| inputFiles | ['dist/index.html'] | This method expects an array of html files. |\n| inputUrls | ['https://maddevs.io'] | This method expects an array of urls to analyze. |\n| inputFolders | ['dist', 'src'] | This method expects an array of folders with html files. |\n| inputSpaFolder | '/dist', 'sitemap.xml', 3000 | This method expects an string of folder with SPA builded files to production \u0026 port for run server. |\n| inputHTMLString | ['\u003chtml\u003eexample\u003c/html\u003e'] | This method expects a string containing HTML. |\n| addRule | function(dom) {} | This method adds a custom rule to check incoming HTML files. |\n| outputObject | function(obj) {} | This method will return the report as a javascript object. |\n| outputJson | function(json) {} | This method will return the report in JSON format. |\n| outputConsole | null | This method must be used at the very end of the chain, because it completes the process in the console. |\n\n## List of rules that are available by default\n\nBelow are the rules that are executed for each file transferred to Seo Analyzer. They are disabled by default and must be added.\n\n### Title Length Rule\n\nChecks the length of tag `\u003ctitle\u003e`. Two parameters are accepted:\n\n- **min:** minimum length of the header\n- **max:** maximum length of the header\n\n```js\n.addRule('titleLengthRule', { min: 10, max: 50 })\n```\n\n### Img Tag With Alt Attribute Rule\n\nChecks if all `\u003cimg\u003e` tags have alt=\"\" attribute.\n\n```js\n.addRule('imgTagWithAltAttributeRule')\n```\n\n### `\u003ca\u003e` Tag With Rel Attribute Rule\n\nChecks if all `\u003ca\u003e` tags have rel=\"\" attribute.\n\n```js\n.addRule('aTagWithRelAttributeRule')\n```\n\n### Meta Base Rule\n\nChecks if the specified **basic** meta tags are present on the page. Accepts one parameter:\n\n- **list:** list of required meta tags\n\n```js\n.addRule('metaBaseRule', { list: ['description', 'viewport'] })\n```\n\n### Meta Social Rule\n\nChecks if the specified **social** meta tags are present on the page. Accepts one parameter:\n\n- **properties:** list of required meta tags\n\n```js\n.addRule('metaSocialRule', {\n  properties: [\n    'og:url',\n    'og:type',\n    'og:site_name',\n    'og:title',\n    'og:description',\n    'og:image',\n    'og:image:width',\n    'og:image:height',\n    'twitter:card',\n    'twitter:text:title',\n    'twitter:description',\n    'twitter:image:src',\n    'twitter:url'\n  ],\n})\n```\n\n### Canonical Link Rule\n\nChecks if a canonical link exists on the page.\n\n```js\n.addRule('canonicalLinkRule')\n```\n\n### Add custom rule\n\nA custom rule is a function that takes a DOM tree argument.\n\n```js\nfunction customRule(dom) {\n  return new Promise(async (resolve, reject) =\u003e {\n    const paragraph = dom.window.document.querySelector('p');\n    if (paragraph) {\n      resolve('');\n    } else {\n      reject('Not found \u003cp\u003e tags');\n    }\n  });\n}\n\n...\n.addRule(customRule)\n...\n```\n\n## Licensing\n\nMIT License\n\nCopyright (c) 2024 Mad Devs\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaddevsio%2Fseo-analyzer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaddevsio%2Fseo-analyzer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaddevsio%2Fseo-analyzer/lists"}