2016-03-28 90 views
0

没有发现我使用的sitemap_generator宝石,并有在配置/ sitemap.rb以下配置:网站地图文件对生产

require 'rubygems' 
require 'sitemap_generator' 

SitemapGenerator::Sitemap.default_host = 'http://www.localhost.com' 

SitemapGenerator::Sitemap.create do 
    add '/', :changefreq => 'daily', :priority => 0.9 
    add '/contact', :changefreq => 'weekly' 

    User.find_each do |user| 
    add users_path(user), lastmod: user.updated_at 
    end 
end 

SitemapGenerator::Sitemap.ping_search_engines 
  • 我改变了我的域名为localhost

的应用托管在heroku上。当我做了heroku run rake sitemap:refresh我得到下面的结果

In '/app/public/': 
+ sitemap.xml.gz           76 links/ 1.53 KB 
Sitemap stats: 76 links/1 sitemaps/0m00s 

Pinging with URL 'http://www.localhost.com/sitemap.xml.gz': 
    Successful ping of Google 
    Successful ping of Bing 

Pinging with URL 'http://www.localhost.com/sitemap.xml.gz': 
    Successful ping of Google 
    Successful ping of Bing 

现在我试图找到sitemap.xml.gz文件及其无处在Heroku。我做了heroku run rake ls,heroku run rake ls tmpheroku run rake ls public,无处可寻。

在过去,我对sitemap.rb这两条线以及:

SitemapGenerator::Sitemap.public_path = 'tmp/' 
SitemapGenerator::Sitemap.sitemaps_path = 'sitemaps/' 

,但仍是网站地图是不会在这个文件夹中生成的。任何线索我做错了什么,并没有生成?

回答

0

我找到了解决方案here

我原来用的是雾AWS宝石和配置sitemap.rb文件:

# Set the host name for URL creation 
SitemapGenerator::Sitemap.default_host = "http://example.com" 
# pick a place safe to write the files 
SitemapGenerator::Sitemap.public_path = 'tmp/' 
# store on S3 using Fog (pass in configuration values as shown above if needed) 
SitemapGenerator::Sitemap.adapter = SitemapGenerator::S3Adapter.new 
# inform the map cross-linking where to find the other maps 
SitemapGenerator::Sitemap.sitemaps_host = "http://#{ENV['FOG_DIRECTORY']}.s3.amazonaws.com/" 
# pick a namespace within your bucket to organize your maps 
SitemapGenerator::Sitemap.sitemaps_path = 'sitemaps/' 

不要忘了安装适配器环境变量:

SitemapGenerator::Sitemap.adapter = SitemapGenerator::S3Adapter.new(fog_provider: 'AWS', 
            aws_access_key_id: <your-access-key-id>, 
            aws_secret_access_key: <your-access-key>, 
            fog_directory: <your-bucket>, 
            fog_region: <your-aws-region e.g. us-west-2>)