-
Notifications
You must be signed in to change notification settings - Fork 278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
subdomain routing support? #43
Comments
Ok so your user links would be like: karl.xyz.com or whatever. When generating your sitemap you can actually set the host on a per-link basis, so you could do something like:
It would be nice to have a :url option so you could just do: Is that what you were looking for? |
No, the links would be for subdomains. For example: subdomain.example.com and so on, where "example.com" is the root domain. So, the host would remain the same. What would be needed is the ability to add the subdomain. Such as: Subdomain.find_each do |sd|
SitemapGenerator.create "#{sd}.{host}"
end I think you would have to create a sitemap for each subdomain, as per Google's guidelines. |
Can you take a look at this thread and see if it helps? #24 From what I understand you just need to create a sitemap for each domain, so you can set your default_host to each full domain e.g. http://subdomain.example.com and add links to it like you would any other sitemap. |
See if something like this works...
|
This works, partially. The individual site maps are generated correctly, but the index only lists one of the site maps. BTW, this seems to be the problem that user chamnap had, and it does not seem to have been resolved. Here is my code: SitemapGenerator::Sitemap.sitemaps_host = "https://s3.amazonaws.com/mysite/"
SitemapGenerator::Sitemap.public_path = 'tmp/'
SitemapGenerator::Sitemap.sitemaps_path = 'sitemaps/'
SitemapGenerator::Sitemap.adapter = SitemapGenerator::WaveAdapter.new
SitemapGenerator::Sitemap.include_index = false
Listing.find_each do |listing|
SitemapGenerator::Sitemap.default_host = "https://#{listing.subdomain}.mysite.com"
SitemapGenerator::Sitemap create do
add ''
end
end |
Ok try this with v2.1.1. There were a couple issues. First is that what was happening is the index file was being overwritten. So we have to generate the sitemaps into separate folders or using different names. Also I fixed some issues with multiple calls to create() in a single sitemap config.
Now works as expected and produces:
Check out the |
Hi Karl, sorry for the delay getting back to you on this. This solution works, and is better. I haven't tried "namer," but it sounds like that will allow me to have all of the sitemaps in a single directory. The main thing I would like to see is a single index file that points to all of the sitemap files. Ideally, it would like like this
|
Ok yeah I wasn't sure about how you intended to structure your sitemaps (everyone seems to need to do it differently :) The only issue with having all the sitemaps using a single index file is that according to the sitemap specs, all links in the sitemap(s) should have the same domain. There is a way to do it using the If you don't care about separating each domain into it's own file, then you can just add all the links to the sitemap as per usual. I'll see if I can fix this scoping issue. |
Good news, there was no problem using groups :D
|
Thanks again for your quick response. Are you sure that you may not include subdomains from the same root (host) domain in the same index? According to the spec,
All of my subdomains are hosted from the same root domain (a single Heroku app). In the end, it does not really matter; I can have an index for each subdomain, if that is necessary. My robot.txt file will have to grow to accommodate. |
Yeah reading it again it's a bit confusing because they compare www.yoursite.com to yourhost.yoursite.com. This post seems to say it's possible: http://www.google.com/support/forum/p/Webmasters/thread?fid=5ba122cf102db3c500046c02075d9f80&tid=5ba122cf102db3c5&hl=en. You just have to prove ownership of each subdomain by adding the Sitemap line to the robots.txt file for each subdomain. So I guess that would point to your main sitemap index. Seems pretty simple since all the robots.txt files would then be the same? You just have to make sure it's accessible on each subdomain. Keep me posted on how it works out. |
Karl, That last construct did not work at all. It produced a single index inside which all the urls were mangled. The approach that is working best for me is: SitemapGenerator::Sitemap.sitemaps_host = "https://s3.amazonaws.com/mysite/"
SitemapGenerator::Sitemap.public_path = 'tmp/'
SitemapGenerator::Sitemap.sitemaps_path = "sitemaps/"
SitemapGenerator::Sitemap.adapter = SitemapGenerator::WaveAdapter.new
SitemapGenerator::Sitemap.include_index = false
index = 1
Listing.active_set.find_each do |listing|
SitemapGenerator::Sitemap.default_host = "https://#{listing.subdomain}.mysite.com"
SitemapGenerator::Sitemap.filename = ('sitemap_' + index.to_s).to_sym
SitemapGenerator::Sitemap.create do
end
index += 1
end This is very close, and is could work. The sitemaps and index file contents are correct, and they are all together in a single sitemaps directory, like so:
The problem now is the naming convention for the sitemaps themselves, with the 1 appended. What I'd like to be able to Bottom line: this will work for me as-is. Getting the namer method to work would be icing on the cake. |
I can give you an example of using a namer, but it would help if you let me know how you want to name them. Also, how were the URLs "mangled" in the index from the If I run exactly this:
My index looks like this:
|
So there was a small bug in the code when both the filename and sitemaps_namer options are used. That's probably why you had issues. It's fixed in v2.1.3. Here's an example using the namer. Working under 2.1.3. You could use the
|
Chris writes:
The text was updated successfully, but these errors were encountered: