{"id":34371840,"url":"https://github.com/jirkapinkas/jsitemapgenerator","last_synced_at":"2026-04-01T23:37:45.452Z","repository":{"id":50114371,"uuid":"11954077","full_name":"jirkapinkas/jsitemapgenerator","owner":"jirkapinkas","description":"Java sitemap generator. This library generates a web sitemap, can ping Google, generate RSS feed, robots.txt and more with friendly, easy to use Java 8 functional style of programming","archived":false,"fork":false,"pushed_at":"2022-12-10T05:50:18.000Z","size":262,"stargazers_count":43,"open_issues_count":3,"forks_count":10,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-12-21T15:35:49.932Z","etag":null,"topics":["aws-lambda","java","java-8","java-8-lambda","java-sitemap-generator","lambda-functions","robots-generator","robots-txt","rss","rss-generator","sitemap","sitemap-generator","web-sitemap"],"latest_commit_sha":null,"homepage":"","language":"Java","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/jirkapinkas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-08-07T15:57:41.000Z","updated_at":"2025-10-03T22:20:27.000Z","dependencies_parsed_at":"2023-01-26T03:16:45.661Z","dependency_job_id":null,"html_url":"https://github.com/jirkapinkas/jsitemapgenerator","commit_stats":null,"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"purl":"pkg:github/jirkapinkas/jsitemapgenerator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jirkapinkas%2Fjsitemapgenerator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jirkapinkas%2Fjsitemapgenerator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jirkapinkas%2Fjsitemapgenerator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jirkapinkas%2Fjsitemapgenerator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jirkapinkas","download_url":"https://codeload.github.com/jirkapinkas/jsitemapgenerator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jirkapinkas%2Fjsitemapgenerator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31292986,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-01T21:15:39.731Z","status":"ssl_error","status_checked_at":"2026-04-01T21:15:34.046Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["aws-lambda","java","java-8","java-8-lambda","java-sitemap-generator","lambda-functions","robots-generator","robots-txt","rss","rss-generator","sitemap","sitemap-generator","web-sitemap"],"created_at":"2025-12-18T10:11:21.538Z","updated_at":"2026-04-01T23:37:45.447Z","avatar_url":"https://github.com/jirkapinkas.png","language":"Java","readme":"# Java sitemap generator\n\n\nThis library generates a web sitemap and can ping Google that it has\nchanged (also it can generate RSS feed and robots.txt). It has friendly, \neasy to use Java 8 functional API and is AWS-lambda friendly.\n\n## Typical usage:\n\nAdd this library to classpath:\n\n    \u003cdependency\u003e\n      \u003cgroupId\u003ecz.jiripinkas\u003c/groupId\u003e\n      \u003cartifactId\u003ejsitemapgenerator\u003c/artifactId\u003e\n      \u003cversion\u003e4.5\u003c/version\u003e\n    \u003c/dependency\u003e\n\nIf you want to use \"ping google / bing\" functionality, also add this library to classpath:\n\n    \u003cdependency\u003e\n        \u003cgroupId\u003ecom.squareup.okhttp3\u003c/groupId\u003e\n        \u003cartifactId\u003eokhttp\u003c/artifactId\u003e\n        \u003cversion\u003e4.2.2\u003c/version\u003e \u003c!-- latest version should be fine, get latest version from https://javalibs.com/artifact/com.squareup.okhttp3/okhttp --\u003e\n    \u003c/dependency\u003e\n\n### Typical usage (web sitemap):\n\n```java\nString sitemap = SitemapGenerator.of(\"https://example.com\")\n    .addPage(\"foo2.html\") // simplest way how to add page - shorthand for addPage(WebPage.of(\"foo2.html\"))\n    .addPage(WebPage.of(\"foo1.html\")) // same as addPage(\"foo1.html\")\n    .addPage(WebPage.builder().name(\"bar.html\").build()) // builder is more complex\n    .addPage(WebPage.builder().maxPriorityRoot().build()) // builder has lots of useful methods\n    .toString();\n```\n\nor sitemap in gzip format:\n\n```java\nbyte[] sitemap = SitemapGenerator.of(\"https://example.com\")\n    .addPage(WebPage.builder().maxPriorityRoot().build())\n    .addPage(\"foo.html\")\n    .addPage(\"bar.html\")\n    .toGzipByteArray();\n```\n\nyou can set default settings (for the subsequent WebPages):\n\n```java\nString sitemap = SitemapGenerator.of(\"https://example.com\")\n    .addPage(WebPage.builder().maxPriorityRoot().build()) // URL will be: \"/\"\n    .defaultExtension(\"html\")\n    .defaultDir(\"dir1\")\n    .addPage(\"foo\") // URL will be: \"dir1/foo.html\"\n    .addPage(\"bar\") // URL will be: \"dir1/bar.html\"\n    .defaultDir(\"dir2\")\n    .addPage(\"hello\") // URL will be: \"dir2/hello.html\"\n    .addPage(\"yello\") // URL will be: \"dir2/yello.html\"\n    // btw. specifying dir and / or extension on WebPage overrides default settings\n    .addPage(WebPage.builder().dir(\"dir3\").extension(null).name(\"test\").build()) // \"dir3/test\"\n    .resetDefaultDir() // resets default dir\n    .resetDefaultExtension() // resets default extension\n    .addPage(WebPage.of(\"mypage\")) // URL will be: \"mypage\"\n    .toString();\n```\n\nor with list of pages:\n\n```java\nList\u003cString\u003e pages = Arrays.asList(\"firstPage\", \"secondPage\", \"otherPage\");\nString sitemap = SitemapGenerator.of(\"https://example.com\")\n        .addPage(WebPage.builder().nameRoot().priorityMax().build())\n        .defaultDir(\"dirName\")\n        .addPages(pages, page -\u003e WebPage.of(page))\n        .toString();\n```\n\nor list of pages in complex data type:\n\n```java\nclass News {\n    private String name;\n    public News(String name) { this.name = name; }\n    public String getName() { return name; }\n}\nList\u003cNews\u003e newsList = Arrays.asList(new News(\"a\"), new News(\"b\"), new News(\"c\"));\nString sitemap = SitemapGenerator.of(\"https://example.com\")\n        .addPage(WebPage.builder().nameRoot().priorityMax().build())\n        .defaultDir(\"news\")\n        .addPages(newsList, news -\u003e WebPage.of(news::getName))\n        .toString();\n```\n\nor to store it to file \u0026 ping Google:\n\n```java\nPing ping = Ping.builder()\n        .engines(Ping.SearchEngine.GOOGLE)\n        .build();\nSitemapGenerator.of(\"https://example.com\")\n    .addPage(WebPage.builder().maxPriorityRoot().changeFreqNever().lastModNow().build())\n    .addPage(\"foo.html\")\n    .addPage(\"bar.html\")\n    // generate sitemap and save it to file ./sitemap.xml\n    .toFile(Paths.get(\"sitemap.xml\"))\n    // inform Google that this sitemap has changed\n    .ping(ping); // this requires okhttp in classpath!!!\n    .callOnSuccess(() -\u003e System.out.println(\"Pinged Google\")) // what will happen on success\n    .catchOnFailure(e -\u003e System.out.println(\"Could not ping Google!\")); // what will happen on error\n```\n\nNote: To ping Google / Bing, you can either use built-in support (requires OkHttp in classpath!!!), \nor you can use your own http client implementation. Supported http clients: Custom OkHttpClient, \nCloseableHttpClient (Apache Http Client), RestTemplate (from Spring). To use your own http client \nimplementation just call on PingBuilder method: httpClient*() and pass inside your implementation.\n\n### How to create sitemap index:\n\n```java\nString sitemapIndex = SitemapIndexGenerator.of(\"https://javalibs.com\")\n    .addPage(\"sitemap-plugins.xml\")\n    .addPage(\"sitemap-archetypes.xml\")\n    .toString();\n```\n\n### How to create RSS channel:\n\n... RSS ISN'T sitemap :-), but it's basically just a list of links (like sitemap) and if you need sitemap, \nthen probably you also need RSS. Note: RssGenerator has lots of common methods with SitemapGenerator.\n\n```java\nString rss = RssGenerator.of(\"https://topjavablogs.com\", \"Top Java Blogs\", \"Best Java Blogs\")\n    .addPage(WebPage.rssBuilder()\n        .pubDate(LocalDateTime.now())\n        .title(\"News Title\")\n        .description(\"News Description\")\n        .link(\"page-name\")\n        .build())\n    .toString();\n```\n\n### How to create robots.txt:\n\n... robots.txt ISN'T sitemap :-), but inside it you reference your sitemap and if you need sitemap, then you probably need robots.txt as well :-)\n\n```java\nString robotsTxt = RobotsTxtGenerator.of(\"https://example.com\")\n        .addSitemap(\"sitemap.xml\")\n        .addRule(RobotsRule.builder().userAgentAll().allowAll().build())\n        .toString();\n```\n\n### How to check sitemap:\n\n- https://hub.docker.com/r/jirkapinkas/sitemap_validator\n    - this tool will crawl any sitemap.xml, parse and check each URL\n    - usable with Docker\n    - can be easily used in CI/CD pipeline\n    - perfect for testing generated sitemap\n    \n### Best practices \u0026 performance\n\n- SitemapGenerator (and other Generator classes) are builders, thus they're not immutable.\n- Also having SitemapGenerator as singleton and at the same time calling addPage() and toString() (in multiple threads) isn't really advised. SitemapGenerator operations aren't thread-safe (with one exception: SitemapGenerator.of(), which creates new instance of SitemapGenerator).\n- When you call addPage(), you store it to Map, where key is page's URL (so you cannot have two items with the same URL in sitemap).\n- toString(), toFile(), toGzipByteArray() methods (terminal operations) generate final sitemap from the Map of objects. So when creating sitemap, most time will be spent executing terminal operation.\n- If you need raw speed for accessing sitemap, I suggest to:\n    - either save sitemap to external file and then just get the data from file\n    - or cache the result of terminal operation\n\n## My other projects:\n\n- [javalibs: (not only) Maven Central search engine](https://javalibs.com)\n- [Java video tutorials](https://javavids.com)\n- [Java školení](https://www.java-skoleni.cz)\n- [SQL školení](https://www.sql-skoleni.cz)\n\n## What I used to upload jsitemapgenerator to Maven Central:\n\n- https://central.sonatype.org/pages/working-with-pgp-signatures.html\n- https://central.sonatype.org/pages/apache-maven.html","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjirkapinkas%2Fjsitemapgenerator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjirkapinkas%2Fjsitemapgenerator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjirkapinkas%2Fjsitemapgenerator/lists"}