Comments (2)
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.gzReply 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.
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)
- Ping failed for Bing: #<OpenURI::HTTPError: 410 Gone> HOT 2
- Feature Request: Remove unwanted options HOT 6
- Is it possible to override the default link options? HOT 3
- How to remove default priority, lastmod and changefreq from all urls HOT 1
- GoogleStorageAdapter - Can't create sitemap on buckets with uniform bucket-level access enabled HOT 3
- Allow disable acl for S3 bucket HOT 1
- Rails on Heroku with S3 sitemap hosting - google didn't like it HOT 2
- 【Worked】Ping failed for Bing: #<OpenURI::HTTPError: 410 Gone> HOT 4
- Is it possible to add additional metadata fields to the xml HOT 5
- Feature request : Make `default_host` optional / Allow full URL instead of path HOT 2
- Entity escaping in XML output
- google search console couldn't fetch sitemap but index is ok HOT 7
- Google search correct ping url HOT 2
- Readme install instructions fail HOT 1
- [BUG] Mobile sitemap link in Readme.md is giving 404
- TimeZone is ignored
- sitemap.xml.gz file not found on server
- Testing with frozen time does not work
- should sitemap show up automatically in google search console? HOT 2
- Should we drop default `lastmod` of `Time.now` as Google says "it needs to consistently match reality"? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sitemap_generator.