Giter Site home page Giter Site logo

Comments (2)

kjvarga avatar kjvarga commented on July 16, 2024

You can use the default_host option to set the host for the sitemap links
as follows:

SitemapGenerator::Sitemap.default_host = "http://myserver.com/myapp/"
SitemapGenerator::Sitemap.create do
  add '/home'
end

That generates a sitemap with 3 links:
http://myserver.com/
http://myserver.com/home
http://myserver.com/myapp/sitemap_index.xml.gz

And a sitemap index with one link:
http://myserver.com/myapp/sitemap1.xml.gz

See how the /home link lost the /myapp part of the URL? That's because
internally I use URI.join and since /home is absolute it strips the path off
the end of the host.

So what you can do is call add with a relative path and it should work:
add 'home'

If you are using the Rails path helpers they may generate absolute URLs too,
so you'd either have to adjust your Rails routes to
take RAILS_RELATIVE_URL_ROOT into account, or manually strip the leading '/'
or send me a patch with a better way of using URI.join() to construct the
URLs.

Cheers,

On Wed, Sep 7, 2011 at 10:46 AM, Tyson Evans <
[email protected]>wrote:

Perhaps an easy configuration I'm missing, but can the sitemap generator
inherit from ENV['RAILS_RELATIVE_URL_ROOT']?

ENV['RAILS_RELATIVE_URL_ROOT'] = '/myapp'

So that generated sitemap links would point to
http://myserver.com/myapp/sitemap_index.xml.gz

Reply to this email directly or view it on GitHub:
#41

Karl Varga
e: [email protected]
w: kjvarga.blogspot.com
c: +1.250.884.9895
Skype: kjvarga

from sitemap_generator.

kjvarga avatar kjvarga commented on July 16, 2024

Hi @tysone I've fixed this little path issue in v2.1.1 so now you can do:

SitemapGenerator::Sitemap.default_host = "http://myserver.com/myapp/"
SitemapGenerator::Sitemap.create do
  add '/home'
end

And all the links generate correctly.

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.