{"id":13509710,"url":"https://github.com/ikeikeikeike/sitemap","last_synced_at":"2025-04-05T20:07:03.003Z","repository":{"id":57548589,"uuid":"50633167","full_name":"ikeikeikeike/sitemap","owner":"ikeikeikeike","description":"Sitemap is the easiest way to generate Sitemaps in Elixir.","archived":false,"fork":false,"pushed_at":"2022-10-30T23:18:28.000Z","size":187,"stargazers_count":106,"open_issues_count":10,"forks_count":24,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-29T19:04:35.406Z","etag":null,"topics":["elixir","sitemap","sitemap-generator"],"latest_commit_sha":null,"homepage":"https://hex.pm/packages/sitemap","language":"Elixir","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/ikeikeikeike.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}},"created_at":"2016-01-29T03:02:56.000Z","updated_at":"2025-03-11T16:50:20.000Z","dependencies_parsed_at":"2022-08-28T11:31:02.672Z","dependency_job_id":null,"html_url":"https://github.com/ikeikeikeike/sitemap","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ikeikeikeike%2Fsitemap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ikeikeikeike%2Fsitemap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ikeikeikeike%2Fsitemap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ikeikeikeike%2Fsitemap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ikeikeikeike","download_url":"https://codeload.github.com/ikeikeikeike/sitemap/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247393569,"owners_count":20931812,"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":["elixir","sitemap","sitemap-generator"],"created_at":"2024-08-01T02:01:11.872Z","updated_at":"2025-04-05T20:07:02.977Z","avatar_url":"https://github.com/ikeikeikeike.png","language":"Elixir","funding_links":[],"categories":["Utilities"],"sub_categories":[],"readme":"# Sitemap\n\n[![Build Status](http://img.shields.io/travis/ikeikeikeike/sitemap.svg?style=flat-square)](http://travis-ci.org/ikeikeikeike/sitemap)\n[![Hex version](https://img.shields.io/hexpm/v/sitemap.svg \"Hex version\")](https://hex.pm/packages/sitemap)\n[![Hex downloads](https://img.shields.io/hexpm/dt/sitemap.svg \"Hex downloads\")](https://hex.pm/packages/sitemap)\n[![Inline docs](https://inch-ci.org/github/ikeikeikeike/sitemap.svg)](http://inch-ci.org/github/ikeikeikeike/sitemap)\n[![hex.pm](https://img.shields.io/hexpm/l/ltsv.svg)](https://github.com/ikeikeikeike/sitemap/blob/master/LICENSE)\n\n\nGenerating sitemap.xml\n\n\n## Installation\n\n\nIf [available in Hex](https://hex.pm/docs/publish), the package can be installed as:\n\n  1. Add sitemap to your list of dependencies in `mix.exs`:\n\n  ```elixir\n  def deps do\n    [{:sitemap, \"~\u003e 1.1\"}]\n  end\n  ```\n\n  2. Ensure sitemap is started before your application:\n\n  ```elixir\n  def application do\n    [extra_applications: [:sitemap]]\n  end\n  ```\n\n#### Usage\n\nsitemap helps you define a module with a `generate` function which will build a sitemap for your site. You must decide how to call `generate` - via a manual Mix task, a recurring background job, or whatever you choose.\n\nThe resulting sitemap is currently written to a file. Because some web hosts do not support writing to the filesystem, we plan to support uploading to S3 in the future.\n\nYou can always specify your own adapter module with a `write/2` function and persist the sitemaps wherever you like.\n\n###### Basic\n\n```elixir\ndefmodule Sitemaps do\n  use Sitemap\n\n  def generate do\n    create do\n      # list each URL that should be included\n      add \"path1\", priority: 0.5, changefreq: \"hourly\", expires: nil, mobile: true\n      # ...\n    end\n\n    # notify search engines (currently Google and Bing) of the updated sitemap\n    ping()\n  end\nend\n```\n\n###### With Phoenix\n\n```elixir\ndefmodule Sitemaps do\n  alias MyAppWeb.{Endpoint, Router.Helpers}\n\n  use Sitemap,\n    host: \"http://#{Application.get_env(:myapp, Endpoint)[:url][:host]}\",\n    files_path: \"priv/static/sitemaps/\",\n    public_path: \"sitemaps/\"\n\n  def generate do\n    create do\n      # list each URL that should be included, using your application's routes\n      add Helpers.entry_path(Endpoint, :index), priority: 0.5, changefreq: \"hourly\", expires: nil\n      add Helpers.entry_path(Endpoint, :about), priority: 0.5, changefreq: \"hourly\", expires: nil\n      # ...\n    end\n\n    # notify search engines (currently Google and Bing) of the updated sitemap\n    ping()\n  end\nend\n```\n\n#### Ways to set sitemap's options\n\n###### Set options via the `use` statement\n\n```elixir\ndefmodule Sitemaps do\n  use Sitemap, compress: false, host: \"http://example.com\"\n\n  def generate do\n    create do\n      add \"path1\", priority: 0.5, changefreq: \"hourly\"\n      add \"path2\", priority: 0.5, changefreq: \"hourly\"\n    end\n\n    ping()\n  end\nend\n```\n\n###### Set options via arguments to `create`\n\n\n```elixir\ndefmodule Sitemaps do\n  use Sitemap\n\n  def generate do\n    create compress: false, host: \"http://example.com\" do\n      add \"path1\", priority: 0.5, changefreq: \"hourly\"\n      add \"path2\", priority: 0.5, changefreq: \"hourly\"\n    end\n\n    ping()\n  end\nend\n```\n\n###### Set options via `Mix` config\n\n\n```elixir\nuse Mix.Config\n\nconfig :sitemap, [\n  compress: false,\n  host: \"http://example.com\",\n]\n\n```\n\n###### Set options via environment variables\n\n```elixir\nSITEMAP_COMPRESS=false SITEMAP_HOST=http://example.com mix run ./sitemap.exs\n```\n\nAnd you guys should follow mix task documents, here:\n\n- https://hexdocs.pm/mix/Mix.Tasks.Run.html\n- https://hexdocs.pm/mix/Mix.Task.html\n\n\n##### Available options\n\n| Name                 | Default Value          | Environment           | -    |\n|:---------------------|:-----------------------|:----------------------|:-----|\n| max_sitemap_files    | 10000                  | SITEMAP_MAXFILES      | Max sitemap links per index file |\n| max_sitemap_links    | 10000                  | SITEMAP_MAXLINKS      | Max links per sitemap  |\n| max_sitemap_news     | 1000                   | SITEMAP_MAXNEWS       | Max news sitemap per index_file  |\n| max_sitemap_images   | 1000                   | SITEMAP_MAXIMAGES     | Max images per url  |\n| max_sitemap_filesize | 5000000                | SITEMAP_MAXFILESIZE   | Bytes |\n| host                 | http://www.example.com | SITEMAP_HOST          | Your domain, also host with http scheme.  |\n| filename             | sitemap                | SITEMAP_FILENAME      | Name of sitemap file.  |\n| files_path           | sitemap                | SITEMAP_SITEMAPS_PATH | After domain path's location on URL.  |\n| public_path          | sitemap                | SITEMAP_PUBLIC_PATH   | Write sitemap files to this local path.  |\n| adapter              | Sitemap.Adapters.File  | SITEMAP_ADAPTER       | You'd change to write each filesystem  |\n| verbose              | true                   | SITEMAP_VERBOSE       | Getting more information in sitemap working.  |\n| compress             | true                   | SITEMAP_COMPRESS      | Gzip compression.  |\n| create_index         | auto                   | SITEMAP_CREATE_INDEX  | Generating sitemps to this directory path.  |\n\n### Features\n\nCurrent Features or To-Do\n\n- [x] [Supports: generate kind of some sitemaps](#supports-generate-kind-of-some-sitemaps)\n  - [x] [News Sitemaps](#news-sitemaps)\n  - [x] [Image Sitemaps](#image-sitemaps)\n  - [x] [Video Sitemaps](#video-sitemaps)\n  - [x] [Alternate Links](#alternate-links)\n  - [x] [Geo Sitemaps](#geo-sitemaps)\n  - [x] [Mobile Sitemaps](#mobile-sitemaps)\n  - [x] [PageMap Sitemap](#pagemap-sitemap)\n- [ ] Supports: write some kind of filesystem and object storage.\n  - [x] Filesystem\n  - [ ] S3\n- [x] Customizable sitemap working\n- [x] Notifies search engines (Google, Bing) of new sitemaps\n- [x] Gives you complete control over your sitemap contents and naming scheme\n- [x] Customizable sitemap compression\n- [ ] Intelligent sitemap indexing\n- [ ] All of completing Examples\n\n\n\n## Supports: generate kind of some sitemaps\n\n\n### News Sitemaps\n\n```elixir\ndefmodule Sitemaps do\n  use Sitemap, compress: false, host: \"http://example.com\"\n\n  def generate do\n    create do\n      add \"index.html\", news: [\n           publication_name: \"Example\",\n           publication_language: \"en\",\n           title: \"My Article\",\n           keywords: \"my article, articles about myself\",\n           stock_tickers: \"SAO:PETR3\",\n           publication_date: \"2011-08-22\",\n           access: \"Subscription\",\n           genres: \"PressRelease\"\n         ]\n    end\n  end\nend\n```\n\n###### Generated Result\n\n```xml\n\u003curl\u003e\n \u003cloc\u003ehttp://www.example.com/index.html\u003c/loc\u003e\n \u003clastmod\u003e2016-05-30T13:13:12Z\u003c/lastmod\u003e\n \u003cnews:news\u003e\n   \u003cnews:publication\u003e\n     \u003cnews:name\u003eExample\u003c/news:name\u003e\n     \u003cnews:language\u003een\u003c/news:language\u003e\n   \u003c/news:publication\u003e\n   \u003cnews:title\u003eMy Article\u003c/news:title\u003e\n   \u003cnews:access\u003eSubscription\u003c/news:access\u003e\n   \u003cnews:genres\u003ePressRelease\u003c/news:genres\u003e\n   \u003cnews:keywords\u003emy article, articles about myself\u003c/news:keywords\u003e\n   \u003cnews:stock_tickers\u003eSAO:PETR3\u003c/news:stock_tickers\u003e\n   \u003cnews:publication_date\u003e2011-08-22\u003c/news:publication_date\u003e\n \u003c/news:news\u003e\n\u003c/url\u003e\n```\n\nLook at [Creating a Google News Sitemap](https://support.google.com/news/publisher/answer/74288) as required.\n\n### Image sitemaps\n\n```elixir\ndefmodule Sitemaps do\n  use Sitemap, compress: false, host: \"http://example.com\"\n\n  def generate do\n    create do\n      add \"index.html\", images: [\n           loc: \"http://example.com/image.jpg\",\n           caption: \"Caption\",\n           title: \"Title\",\n           license: \"https://github.com/ikeikeikeike/sitemap/blob/master/LICENSE\",\n           geo_location: \"Limerick, Ireland\",\n         ]\n    end\n  end\nend\n```\n\n###### Generated Result\n\n```xml\n\u003curl\u003e\n \u003cloc\u003ehttp://www.example.com/image.html\u003c/loc\u003e\n \u003clastmod\u003e2016-05-31T13:32:40Z\u003c/lastmod\u003e\n \u003cimage:image\u003e\n   \u003cimage:loc\u003ehttp://example.com/image.jpg\u003c/image:loc\u003e\n   \u003cimage:caption\u003eCaption\u003c/image:caption\u003e\n   \u003cimage:title\u003eTitle\u003c/image:title\u003e\n   \u003cimage:license\u003ehttps://github.com/ikeikeikeike/sitemap/blob/master/LICENSE\u003c/image:license\u003e\n   \u003cimage:geo_location\u003eLimerick, Ireland\u003c/image:geo_location\u003e\n \u003c/image:image\u003e\n\u003c/url\u003e\n```\n\nLook at [Image sitemaps](https://support.google.com/webmasters/answer/178636) as required.\n\n\n### Video sitemaps\n\n```elixir\ndefmodule Sitemaps do\n  use Sitemap, compress: true, host: \"http://example.com\"\n\n  def generate do\n    create do\n      add \"index.html\", videos: [\n           thumbnail_loc: \"http://www.example.com/thumbs/123.jpg\",\n           title: \"Grilling steaks for summer\",\n           description: \"Alkis shows you how to get perfectly done steaks every time\",\n           content_loc: \"http://www.example.com/video123.flv\",\n           player_loc: \"http://www.example.com/videoplayer.swf?video=123\",\n           allow_embed: true,\n           autoplay: true,\n           duration: 600,\n           expiration_date: \"2009-11-05T19:20:30+08:00\",\n           publication_date: \"2007-11-05T19:20:30+08:00\",\n           rating: 0.5,\n           view_count: 1000,\n           tags: ~w(tag1 tag2 tag3),\n           tag: \"tag4\",\n           category: \"Category\",\n           family_friendly: true,\n           restriction: \"IE GB US CA\",\n           relationship: true,\n           gallery_loc: \"http://cooking.example.com\",\n           gallery_title: \"Cooking Videos\",\n           price: \"1.99\",\n           price_currency: \"EUR\",\n           price_type: \"own\",\n           price_resolution: \"HD\",\n           uploader: \"GrillyMcGrillerson\",\n           uploader_info: \"http://www.example.com/users/grillymcgrillerson\",\n           live: true,\n           requires_subscription: false\n         ]\n    end\n  end\nend\n\n```\n\n###### Generated Result\n\n```xml\n\u003curl\u003e\n \u003cloc\u003ehttp://www.example.com/video.html\u003c/loc\u003e\n \u003clastmod\u003e2016-05-31T12:51:47Z\u003c/lastmod\u003e\n \u003cvideo:video\u003e\n   \u003cvideo:title\u003eGrilling steaks for summer\u003c/video:title\u003e\n   \u003cvideo:description\u003eAlkis shows you how to get perfectly done steaks every time\u003c/video:description\u003e\n   \u003cvideo:player_loc allow_embed=\"yes\" autoplay=\"ap=1\"\u003ehttp://www.example.com/videoplayer.swf?video=123\u003c/video:player_loc\u003e\n   \u003cvideo:content_loc\u003ehttp://www.example.com/video123.flv\u003c/video:content_loc\u003e\n   \u003cvideo:thumbnail_loc\u003ehttp://www.example.com/thumbs/123.jpg\u003c/video:thumbnail_loc\u003e\n   \u003cvideo:duration\u003e600\u003c/video:duration\u003e\n   \u003cvideo:gallery_loc title=\"Cooking Videos\"\u003ehttp://cooking.example.com\u003c/video:gallery_loc\u003e\n   \u003cvideo:rating\u003e0.5\u003c/video:rating\u003e\n   \u003cvideo:view_count\u003e1000\u003c/video:view_count\u003e\n   \u003cvideo:expiration_date\u003e2009-11-05T19:20:30+08:00\u003c/video:expiration_date\u003e\n   \u003cvideo:publication_date\u003e2007-11-05T19:20:30+08:00\u003c/video:publication_date\u003e\n   \u003cvideo:tag\u003etag1\u003c/video:tag\u003e\n   \u003cvideo:tag\u003etag2\u003c/video:tag\u003e\n   \u003cvideo:tag\u003etag3\u003c/video:tag\u003e\n   \u003cvideo:tag\u003etag4\u003c/video:tag\u003e\n   \u003cvideo:category\u003eCategory\u003c/video:category\u003e\n   \u003cvideo:family_friendly\u003eyes\u003c/video:family_friendly\u003e\n   \u003cvideo:restriction relationship=\"allow\"\u003eIE GB US CA\u003c/video:restriction\u003e\n   \u003cvideo:uploader info=\"http://www.example.com/users/grillymcgrillerson\"\u003eGrillyMcGrillerson\u003c/video:uploader\u003e\n   \u003cvideo:price currency=\"EUR\" resolution=\"HD\" type=\"own\"\u003e1.99\u003c/video:price\u003e\n   \u003cvideo:live\u003eyes\u003c/video:live\u003e\n   \u003cvideo:requires_subscription\u003eno\u003c/video:requires_subscription\u003e\n \u003c/video:video\u003e\n\u003c/url\u003e\n```\n\nLook at [Video sitemaps](https://developers.google.com/webmasters/videosearch/sitemaps#adding-video-content-to-a-sitemap) as required.\n\n\n### Alternate Links\n\n```elixir\ndefmodule Sitemaps do\n  use Sitemap, compress: true, host: \"http://example.com\"\n\n  def generate do\n    create do\n      add \"index.html\", alternates: [\n           href: \"http://www.example.de/index.html\",\n           lang: \"de\",\n           nofollow: true,\n           media: \"only screen and (max-width: 640px)\"\n         ]\n    end\n  end\nend\n```\n\n###### Generated Result\n\n```xml\n\u003curl\u003e\n \u003cloc\u003ehttp://www.example.com/video.html\u003c/loc\u003e\n \u003clastmod\u003e2016-06-01T14:05:05Z\u003c/lastmod\u003e\n \u003cxhtml:link href=\"http://www.example.de/index.html\" hreflang=\"de\" media=\"only screen and (max-width: 640px)\" rel=\"alternate nofollow\"/\u003e\n\u003c/url\u003e\n```\n\nLook at [Alternate Links](https://support.google.com/webmasters/answer/2620865) as required.\n\n\n### Geo Sitemaps\n\n```elixir\ndefmodule Sitemaps do\n  use Sitemap, compress: true, host: \"http://example.com\"\n\n  def generate do\n    create do\n      add \"geo.html\", alternates: [\n           format: \"kml\"\n         ]\n    end\n  end\nend\n```\n\n###### Generated Result\n\n```xml\n\u003curl\u003e\n \u003cloc\u003ehttp://www.example.com/geo.html\u003c/loc\u003e\n \u003clastmod\u003e2016-06-01T14:15:25Z\u003c/lastmod\u003e\n \u003cgeo:geo\u003e\n   \u003cgeo:format\u003ekml\u003c/geo:format\u003e\n \u003c/geo:geo\u003e\n\u003c/url\u003e\n```\n\nLook at [Geo Sitemaps](https://support.google.com/webmasters/answer/94555) as required.\n\n\n### Mobile Sitemaps\n\n```elixir\ndefmodule Sitemaps do\n  use Sitemap, compress: true, host: \"http://example.com\"\n\n  def generate do\n    create do\n      add \"mobile.html\", priority: 0.5, changefreq: \"hourly\", mobile: true\n    end\n  end\nend\n```\n\n###### Generated Result\n\n```xml\n\u003curl\u003e\n \u003cloc\u003ehttp://www.example.com/mobile.html\u003c/loc\u003e\n \u003clastmod\u003e2016-06-01T14:24:44Z\u003c/lastmod\u003e\n \u003cchangefreq\u003ehourly\u003c/changefreq\u003e\n \u003cpriority\u003e0.5\u003c/priority\u003e\n \u003cmobile:mobile/\u003e\n\u003c/url\u003e\n```\n\nLook at [Mobile Sitemaps](https://support.google.com/webmasters/answer/6082207) as required.\n\n\n### PageMap sitemap\n\n```elixir\ndefmodule Sitemaps do\n  use Sitemap, compress: true, host: \"http://example.com\"\n\n  def generate do\n    create do\n      add \"pagemap.html\", pagemap: [\n        dataobjects: [[\n          type: \"document\",\n          id: \"hibachi\",\n          attributes: [\n            [name: \"name\",   value: \"Dragon\"],\n            [name: \"review\", value: \"3.5\"],\n          ]\n        ]]\n      ]\n    end\n  end\nend\n```\n\n###### Generated Result\n\n```xml\n\u003curl\u003e\n \u003cloc\u003ehttp://www.example.com/pagemap.html\u003c/loc\u003e\n \u003clastmod\u003e2016-06-02T17:01:17Z\u003c/lastmod\u003e\n \u003cPageMap\u003e\n   \u003cDataObject id=\"hibachi\" type=\"document\"\u003e\n     \u003cAttribute name=\"name\"\u003eDragon\u003c/Attribute\u003e\n     \u003cAttribute name=\"review\"\u003e3.5\u003c/Attribute\u003e\n   \u003c/DataObject\u003e\n \u003c/PageMap\u003e\n\u003c/url\u003e\n```\n\nLook at [PageMap sitemap](https://developers.google.com/custom-search/docs/structured_data#addtositemaps) as required.\n\n\n### Additional links into the Sitemap Index\n\n\n```elixir\ncreate do\n  add_to_index \"/mysitemap1.xml.gz\"\n  add_to_index \"/alternatemap.xml\"\n  add_to_index \"/changehost.xml.gz\", host: \"http://something.com\"\n\n  add ...\n  add ....\nend\n```\n\n```xml\n\u003c?xml version='1.0' encoding='utf-8'?\u003e\n\u003csitemapindex xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemalocation=\"http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd\" xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"\u003e\n \u003csitemap\u003e\n   \u003cloc\u003ehttp://example.com/mysitemap1.xml.gz\u003c/loc\u003e\n   \u003clastmod\u003e2017-05-19T11:42:45+09:00\u003c/lastmod\u003e\n \u003c/sitemap\u003e\n \u003csitemap\u003e\n   \u003cloc\u003ehttp://example.com/mysitemap2.xml.gz\u003c/loc\u003e\n   \u003clastmod\u003e2017-05-19T11:42:45+09:00\u003c/lastmod\u003e\n \u003c/sitemap\u003e\n \u003csitemap\u003e\n   \u003cloc\u003ehttp://something.com/changehost.xml.gz\u003c/loc\u003e\n   \u003clastmod\u003e2017-05-19T11:42:45+09:00\u003c/lastmod\u003e\n \u003c/sitemap\u003e\n \u003csitemap\u003e\n   \u003cloc\u003ehttp://example.com/sitemap1.xml.gz\u003c/loc\u003e\n   \u003clastmod\u003e2017-05-19T11:42:45+09:00\u003c/lastmod\u003e\n \u003c/sitemap\u003e\n\u003c/sitemapindex\u003e\n```\n\n\n### Known issue\n\n- [Compilation error with ** (EXIT) no process](https://github.com/ikeikeikeike/sitemap/issues/5#issue-200979852)\n\n\n### Inspired by\n\n- [sitemap_generator](http://github.com/kjvarga/sitemap_generator)\n- [go-sitemap-generator](http://github.com/ikeikeikeike/go-sitemap-generator)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fikeikeikeike%2Fsitemap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fikeikeikeike%2Fsitemap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fikeikeikeike%2Fsitemap/lists"}