Git Product home page Git Product logo

Comments (7)

kjvarga avatar kjvarga commented on July 17, 2024

Hi there,

You can do what you want to with something like the following. You may need to pass more options in the call to add to set the host, depending on your setup.

SitemapGenerator.yield_sitemap = true
SitemapGenerator::Sitemap.create do |sm|
  sm.sitemap_index.add '/theirsitemap.xml.gz'
  sm.add '/mylinks.html'
end

from sitemap_generator.

triemstr avatar triemstr commented on July 17, 2024

Excellent, I'll try it and I'll close this. Might be nice if the sitemap_index.add found its way to the readme documentation...it was hard for me to navigate through the code to find that this does indeed exist.

Thank you for your hard work on this gem.

Kevin

from sitemap_generator.

triemstr avatar triemstr commented on July 17, 2024

When I try this:

SitemapGenerator.yield_sitemap = true

SitemapGenerator::Sitemap.create do |sitemap|
sitemap.sitemap_index.add '/blog/sitemap1.xml.gz'
end

I get:

rake aborted!
undefined method `sitemap_index' for #SitemapGenerator::Interpreter:0x5634b40

Any other thoughts?

from sitemap_generator.

kjvarga avatar kjvarga commented on July 17, 2024

Ok try this. It works for me:

SitemapGenerator::Sitemap.default_host = 'http://example.com'
SitemapGenerator::Sitemap.create do
  @linkset.sitemap_index.add '/blog/sitemap1.xml.gz', :host => 'http://example.com'
end

You'll have to specify the :host on your link, but it gets the job done. In the next release I'll think about exposing the LinkSet instance through a method...maybe called 'sitemap'

from sitemap_generator.

triemstr avatar triemstr commented on July 17, 2024

You are the man. Works as advertised by referencing @linkset directly and adding the host.

BTW, I donated to the cause...wish I could do more but hoping others will put some in, too. I wouldn't be able to auto-generate a sitemap well without this gem of a gem. Thanks for the fix!

from sitemap_generator.

kjvarga avatar kjvarga commented on July 17, 2024

Ah yes, thanks for the donation! I noticed that. That is awesome man, thanks a lot.

from sitemap_generator.

triemstr avatar triemstr commented on July 17, 2024

Thank you for adding this:

v3.1.0: Add add_to_index method to add links to the sitemap index. Add sitemap method for accessing the LinkSet instance from within create(). Don't modify options hashes passed to methods. Fix and improve yield_sitemap option handling.

from sitemap_generator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.