{"id":16732406,"url":"https://github.com/carpodaster/ar_sitemapper","last_synced_at":"2026-01-01T21:58:50.983Z","repository":{"id":138399711,"uuid":"779023","full_name":"carpodaster/ar_sitemapper","owner":"carpodaster","description":"Enhances your ActiveRecord model to export its data to a sitemap in an intuitive way","archived":false,"fork":false,"pushed_at":"2015-12-03T23:08:30.000Z","size":68,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-15T19:29:18.691Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/carpodaster.png","metadata":{"files":{"readme":"README.md","changelog":"Changelog.rdoc","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":"2010-07-16T15:07:45.000Z","updated_at":"2015-12-03T22:15:21.000Z","dependencies_parsed_at":"2023-03-14T04:01:02.305Z","dependency_job_id":null,"html_url":"https://github.com/carpodaster/ar_sitemapper","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/carpodaster/ar_sitemapper","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carpodaster%2Far_sitemapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carpodaster%2Far_sitemapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carpodaster%2Far_sitemapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carpodaster%2Far_sitemapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/carpodaster","download_url":"https://codeload.github.com/carpodaster/ar_sitemapper/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carpodaster%2Far_sitemapper/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28164128,"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","status":"online","status_checked_at":"2026-01-01T02:00:06.694Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-10-12T23:44:16.750Z","updated_at":"2026-01-01T21:58:50.967Z","avatar_url":"https://github.com/carpodaster.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ActiveRecord Sitemapper [![Build Status](https://travis-ci.org/carpodaster/ar_sitemapper.svg?branch=master)](https://travis-ci.org/carpodaster/ar_sitemapper)\n## Low-level sitemap-building\n\nThe standard approach to generate XML sitemaps for a Ruby on Rails application\nseems to be creating a special SitemapsController with xml views and a bit\nof routes.rb magic.\n\nI used to generate sitemaps created thus via a nightly rake task to have them\ncached and delivered statically by Apache. That felt wrong, I wanted a more\n\"low-level\" approach. Actually, as low-level as possible and I ended up at\nActiveRecord::Base: this plugin enhances your ActiveRecord model to export\nits data to a sitemap in an intuitive way.\n\nAlso yes, I know there are probably a gazillion projects covering this already.\n\n## Installation\n\nTo add **ar_sitemapper** to your Rails 3 project, add it to your Gemfile:\n\n```\ngem 'ar_sitemapper', '~\u003e 1.0.0'\n```\n\n## Usage\n\n### ActiveRecord drop-in\n\nYou can use `build_sitemap` directly on any ActiveRecord model. The following\nexample will create a sitemap of all your Content objects as Rails.root/public/sitemap_contents.xml.gz:\n\n```ruby\nContent.build_sitemap :all do |content, xml|\n  xml.loc content_url(content)\n  xml.changefreq 'weekly'\n  xml.lastmod content.updated_at.strftime(\"%Y-%m-%d\")\n  xml.priority 0.5\nend\n```\n\nYou can pass ActiveRecord::Base.find options as arguments to `build_sitemap`\nto fine-tune the selection of objects you want to extract:\n\n```ruby\nPost.build_sitemap :all, :conditions =\u003e [\"published IS TRUE\"], :order =\u003e :name do |post, xml|\n  # do stuff here\nend\n```\n\n**Note**: if you want to use your named route helpers in the block, be sure to have\nActionController::UrlWriter included. Setting default_url_options[:host]\nis helpful, too.\n\n### Output\n\n**ar_sitemapper** will derive its sitemap filename from the model's name and will\ndefault to Gzip compressed output. If can write to `stdout` as well if `file`\nis explicitely set to `nil` or `false`.\n\nIt will automatically compress your XML sitemap with Gzip if the filename parameter suggests it (ie. ends with \".gz\"). Alternatively, you can enforce or disable Gzip compression by passing true or false to the `gzip` option.\n\nBoth of the following examples will create a gzip'ed file named \"test.xml.gz\":\n\n```ruby\nContent.build_sitemap :all, :file =\u003e \"test.xml.gz\" { |content, xml| ... }\nContent.build_sitemap :all, :file =\u003e \"test.xml\", :gzip =\u003e true { |content, xml| ... }\n```\n\n### Sitemaps for static data\n\nSitemap creation is done via a block, so you can do whatever you want in it. For added flexibility, you can use **ar_sitemapper** with arbitrary data collections (ie. generating sitemaps for static content). Future versions will support YAML configuration of such static content.\n\n```ruby\nsites = [\n  { :url =\u003e \"http://example.com/your/static/content1.html\", :freq =\u003e \"always\",  :prio =\u003e \"1.0\" },\n  { :url =\u003e \"http://example.com/your/static/content2.html\", :freq =\u003e \"monthly\", :prio =\u003e \"0.3\" },\n]\n\nAegisNet::Sitemapper::Generator.create(sites) do |site, xml|\n  xml.loc site[:url]\n  xml.changefreq site[:freq]\n  xml.priority site[:prio]\nend\n```\n\n### YAML configuration\nSitemapper supports configuration via a YAML file which is expected to reside in `Rails.root/config/sitemaps.yml`.\n\n#### Supported top level configuration options\n* **default_host**: base hostname used for url generation (mandatory).\n* **local_path**: where to store the generated sitemaps on the local system (mandatory).\n* **ping**: boolean whether or not to ping search engines on successful sitemap generation.\n* **index**: options for the main sitemap index file, ie. the file that references all others.\n* **static**: options for the sitemap that lists URLs to static content (ie. URLs not\n  necessarily related to AR models)\n* **models**: options for model-related URLset sitemaps\n* **ping**: a list of search engines' ping services.\n\n#### The `index` option\n* **sitemapfile**: the name of the the generated sitemap.\n* **includes**: an array of sitemaps that should be included in the sitemap index but\n  are _not_ generated directly through AR:Sitemapper (eg. a KML-sitemap).\n\n#### The `static` option\n* **sitemapfile**: the name of the the generated sitemap.\n* **urlset**: a list of static pages to include into the sitemap. Every item must\n  have a **loc** element. A `changefreq` and `priority` element is optional and defaults to _weekly_ and _0.5_, respectively.\n\n#### The `model` option\nA list of models to create sitemaps for. The key must be the downcased und\nunderscored name of the model. Supported / required options for every model-based\nsitemap are:\n* **sitemapfile**: the name of the the generated sitemap (mandatory).\n* **loc**: a Proc definition to generate the URLs for each object with (mandatory).\n* **changefreq**: optional, defaults to 'weekly'\n* **priority**: optional, defaults to '0.5'\n* **lastmod**: you can use ERB to insert the date you desire.\n* **conditions**: conditions to be merged into the finder of `build_sitemap` (optional).\n* **scope**: a named scope to find objects with\n\n#### Sample YAML file\n\n```yaml\ndefault_host: \"www.example.com\"\nlocal_path: \u003c%= File.join Rails.root, \"public\", \"sitemaps\" %\u003e\nping: true\nindex:\n  sitemapfile: \"sitemap_index.xml\"\n  includes:\n    -\n      loc: some_other_sitemap.xml\nstatic:\n  sitemapfile: \"sitemap_static.xml.gz\"\n  urlset:\n    -\n      loc: \"http://www.example.com/static/content\"\n      changefreq: weekly\n      priority: 1.0\n    -\n      loc: \"http://www.example.com/another/page\"\n      changefreq: weekly\n      priority: 1.0\nmodels:\n  foo_bar:\n    sitemapfile: sitemap_foo_bars.xml.gz\n    lastmod: \u003c%= 2.days.ago %\u003e\n    loc: Proc.new {|object| foo_bar_path(object) }\n    changefreq: weekly\n    priority: 0.7\n    conditions: \"foo \u003e 1\"\n  acme:\n    sitemapfile: sitemap_proctests.xml.gz\n    scope: liquid\n    lastmod: \u003c%= Acme.find(:last, :order =\u003e :updated_at).updated_at %\u003e\n    loc: Proc.new {|object| acme_path(object) }\n    changefreq: weekly\n    priority: 0.8\npings:\n  - http://submissions.ask.com/ping?sitemap=\n  - http://www.google.com/webmasters/sitemaps/ping?sitemap=\n  - http://search.yahooapis.com/SiteExplorerService/V1/updateNotification?appid=YahooDemo\u0026url=\n  - http://www.bing.com/webmaster/ping.aspx?siteMap=\n```\n\n### Rake task\nThe gem provides a rake task to rebuild all sitemaps from its config file:\n\n```\nrake sitemapper:rebuild\n```\n\n## .plan\n* support KML files\n* allow for a custom iterator supplied as Proc for Generator::create (ie. to make use of ARs batch finding)\n* cleanup\n* more flexible syntax for conditions in yml file\n* guess RESTful object path and make Proc object for loc in models optional\n* Install a sample sitemap.yml file\n\n---\n\nCopyright (c) 2010-2013 Carsten Zimmermann, released under a BSD-type license\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarpodaster%2Far_sitemapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcarpodaster%2Far_sitemapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarpodaster%2Far_sitemapper/lists"}