Giter Site home page Giter Site logo

Comments (7)

kjvarga avatar kjvarga commented on July 16, 2024

Hi chamnap,

You are in luck! If you had asked a little while ago, it would have been very difficult, but recent changes I've made make it very easy.

I'm still working on the API, so this consider this experimental stuff. Put this in your config/sitemap.rb and refresh your sitemaps. You'll get an exception at the end, but the sitemaps should be created ok.

Alternatively you can add require 'sitemap_generator' to the script and run it with ./script/runner config/sitemap.rb and you won't get an exception, but you also won't see the stats output.

SitemapGenerator::Sitemap.yahoo_app_id = false

SitemapGenerator::Sitemap.sitemaps_path = "en/"
SitemapGenerator::Sitemap.default_host = "http://www.en.example.com"
SitemapGenerator::Sitemap.create do
  add '/english-site'
end

SitemapGenerator::Sitemap.sitemaps_path = "fr/"
SitemapGenerator::Sitemap.default_host = "http://www.fr.example.com"
SitemapGenerator::Sitemap.create do 
  add '/french-site'
end

SitemapGenerator::Sitemap.sitemaps_path = "ru/"
SitemapGenerator::Sitemap.default_host = "http://www.ru.example.com"
SitemapGenerator::Sitemap.create do 
  add '/russian-site'
end

from sitemap_generator.

chamnap avatar chamnap commented on July 16, 2024

Alright, thanks for reply. I figured out by go through the code base, but a slicely different approach.

from sitemap_generator.

kjvarga avatar kjvarga commented on July 16, 2024

Closing

from sitemap_generator.

chamnap avatar chamnap commented on July 16, 2024

It seems it doesn't work in a loop. The first domain is generated correctly in sitemap file, but the rest doesn't (only example.com).

from sitemap_generator.

kjvarga avatar kjvarga commented on July 16, 2024

What do you mean "it doesn't work in a loop"? You'll have to paste your code for me to understand what you mean. The example I gave works fine, as does this:

SitemapGenerator::Sitemap.yahoo_app_id = false

%w[en fr ru].each do |domain|
  SitemapGenerator::Sitemap.sitemaps_path = "#{domain}/"
  SitemapGenerator::Sitemap.default_host = "http://www.#{domain}.example.com"
  SitemapGenerator::Sitemap.create do
    add '/whatever'
  end
end

from sitemap_generator.

chamnap avatar chamnap commented on July 16, 2024

Well, the above code works fine, except in the sitemap file of the second and third domain name, the generated domain name is http://example.com/.

from sitemap_generator.

kjvarga avatar kjvarga commented on July 16, 2024

Hmm, yeah the host in the sitemap file e.g. sitemap1.xml is correct, but the host in the index file is not.

I'll take a look when I get a chance.

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.