https://github.com/itgalaxy/generate-robotstxt
Generator robots.txt for node js
https://github.com/itgalaxy/generate-robotstxt
cli generator-robots robot robots robots-generator robots-txt robotstxt
Last synced: 8 months ago
JSON representation
Generator robots.txt for node js
- Host: GitHub
- URL: https://github.com/itgalaxy/generate-robotstxt
- Owner: itgalaxy
- License: mit
- Created: 2014-11-07T10:55:31.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T21:37:09.000Z (over 3 years ago)
- Last Synced: 2025-08-19T20:55:29.400Z (10 months ago)
- Topics: cli, generator-robots, robot, robots, robots-generator, robots-txt, robotstxt
- Language: JavaScript
- Size: 2.86 MB
- Stars: 65
- Watchers: 5
- Forks: 8
- Open Issues: 18
-
Metadata Files:
- Readme: readme.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# generate-robotstxt
[](https://www.npmjs.org/package/generate-robotstxt)
[](https://travis-ci.org/itgalaxy/generate-robotstxt)
[](https://david-dm.org/itgalaxy/generate-robotstxt)
[](https://david-dm.org/itgalaxy/generate-robotstxt?type=dev)
Awesome generator robots.txt.
## Installation
```shell
npm install --save-dev generate-robotstxt
```
## Usage
```js
import robotstxt from "generate-robotstxt";
robotstxt({
policy: [
{
userAgent: "Googlebot",
allow: "/",
disallow: "/search",
crawlDelay: 2,
},
{
userAgent: "OtherBot",
allow: ["/allow-for-all-bots", "/allow-only-for-other-bot"],
disallow: ["/admin", "/login"],
crawlDelay: 2,
},
{
userAgent: "*",
allow: "/",
disallow: "/search",
crawlDelay: 10,
cleanParam: "ref /articles/",
},
],
sitemap: "http://example.com/sitemap.xml",
host: "http://example.com",
})
.then((content) => {
console.log(content);
return content;
})
.catch((error) => {
throw error;
});
```
## File based configuration
**robots-txt.config.js**
```js
module.exports = {
policy: [
{
userAgent: "Googlebot",
allow: "/",
disallow: ["/search"],
crawlDelay: 2,
},
{
userAgent: "OtherBot",
allow: ["/allow-for-all-bots", "/allow-only-for-other-bot"],
disallow: ["/admin", "/login"],
crawlDelay: 2,
},
{
userAgent: "*",
allow: "/",
disallow: "/search",
crawlDelay: 10,
cleanParam: "ref /articles/",
},
],
sitemap: "http://example.com/sitemap.xml",
host: "http://example.com",
};
```
## CLI
```shell
Awesome generator robots.txt
Usage generate-robotstxt [options]
Options:
--config Path to a specific configuration file.
```
## Contribution
Feel free to push your code if you agree with publishing under the MIT license.
## [Changelog](CHANGELOG.md)
## [License](LICENSE)