robot.txt generator
A Maven plugin for generating robots.txt files. It enables a 'robots.txt as code' approach through custom class-based content definition.
- API:robots.txt generate api
- Maven Plugin: robotxtgen-api with maven-plugin integration.
Follow these steps to integrate and use the robotxtgen-maven-plugin in your project:
<dependency>
<groupId>io.github.internetms52</groupId>
<artifactId>robotxtgen-api</artifactId>
<version>0.3.1</version>
</dependency>
import io.github.internetms52.robotxt.api.RobotTextConfigProvider;
import io.github.internetms52.robotxt.api.RobotTextDataInstance;
public class MyRobotTextConfig implements RobotTextConfigProvider {
@Override
public RobotTextDataInstance robotTextDataInstance() {
// Implement this method to return your RobotTextDataInstance
// This is where you define the content of your robots.txt
return RobotTextDataInstance.builder()
.addUserAgentSection(
UserAgentSection.builder()
.userAgent("*")
.addDisallow("/private/")
.addAllow("/public/")
.crawlDelay(10)
.build()
).addUserAgentSection(
UserAgentSection.builder()
.userAgent("Googlebot")
.addDisallow("/google-specific/")
.build()
).addUserAgentSection(
UserAgentSection.builder()
.userAgent("Bingbot")
.addDisallow("/bing-specific/")
.build()
).addSiteMap("https://www.example.com/sitemap.xml")
.host("www.example.com")
.build();
}
}
<plugin>
<groupId>io.github.internetms52</groupId>
<artifactId>robotxtgen-maven-plugin</artifactId>
<version>0.3.1</version>
<configuration>
<configClass>com.example.MyRobotTextConfig</configClass>
</configuration>
<executions>
<execution>
<goals>
<goal>generate-robotstxt</goal>
</goals>
</execution>
</executions>
</plugin>
By default, the plugin generates the robots.txt file in the target
directory.
mvn clean compile
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.