Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

big_sitemap

Package Overview
Dependencies
Maintainers
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

big_sitemap

  • 1.1.0
  • Rubygems
  • Socket score

Version published
Maintainers
2
Created
Source

= BigSitemap

BigSitemap is a {Sitemap}[http://sitemaps.org] generator suitable for applications with greater than 50,000 URLs. It splits large Sitemaps into multiple files, gzips the files to minimize bandwidth usage, supports increment updates, can be set up with just a few lines of code and is compatible with just about any framework.

BigSitemap is best run periodically through a Rake/Thor task.

require 'big_sitemap'

include Rails.application.routes.url_helpers # Allows access to Rails routes

BigSitemap.generate(:url_options => {:host => 'example.com'}, :document_root => "#{APP_ROOT}/public") do # Add a static page add '/about'

# Add some URLs from your Rails application
Post.find(:all).each do |post|
  add post_path(post)
end

# Add some URLs with additional options
Product.find(:all).each do |product|
  add product_path(product), :change_frequency => 'daily', :priority => 0.5
end

end

The code above will create a minimum of two files:

  1. public/sitemaps/sitemap_index.xml.gz
  2. public/sitemaps/sitemap.xml.gz

If your sitemaps grow beyond 50,000 URLs (this limit can be overridden with the :max_per_sitemap option), the sitemap files will be partitioned into multiple files (sitemap_1.xml.gz, sitemap_2.xml.gz, ...).

=== Framework-specific Classes

Use the framework-specific classes to take advantage of built-in shortcuts.

==== Rails

BigSiteMapRails deals with setting the :document_root and :url_options initialization options.

==== Merb

BigSitemapMerb deals with setting the :document_root initialization option.

== Install

Via gem:

sudo gem install big_sitemap

== Advanced

=== Initialization Options

  • :url_options -- hash with :host, optionally :port and :protocol
  • :base_url -- string alternative to :url_options, e.g. 'https://example.com:8080/'
  • :url_path -- string path_name to sitemaps folder, defaults to :document_path
  • :document_root -- string
  • :document_path -- string document path for sitemaps, relative to :document_root, defaults to empty string (putting sitemap files in the document root directory)
  • :document_full -- string absolute document path to generation folder - defaults to :document_root/:document_path
  • :max_per_sitemap -- 50000, which is the limit dictated by Google but can be less
  • :gzip -- true
  • :ping_google -- true
  • :ping_yahoo -- false, needs :yahoo_app_id
  • :ping_bing -- false
  • :ping_ask -- false
  • :ping_yandex -- false
  • :partial_update -- false

=== Change Frequency, Priority and Last Modified

You can control "changefreq", "priority" and "lastmod" values for each record individually by passing them as optional arguments when adding URLs:

add(product_path(product), { :change_frequency => 'daily', :priority => 0.5, :last_modified => product.updated_at })

=== Partial Update

If you enable :partial_update, the filename will include the id of the first entry. This is perfect to update just the last file with new entries without the need to re-generate files being already there. You must pass the entry's id in when adding the URL. For example:

BigSitemap.generate(:base_url => 'http://example.com', :partial_update => true) do Widget.find_in_batches(:conditions => "id > #{get_last_id}").each do |widget| add widget_path(widget), :id => widget.id end end

== TODO

Tests for framework-specific components.

== Credits

Thanks to Alastair Brunton and Harry Love, who's work provided a starting point for this library.

Thanks also to those who have contributed patches:

== Copyright

Copyright (c) 2010 Stateless Systems (http://statelesssystems.com). See LICENSE for details.

FAQs

Package last updated on 06 Feb 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc