10
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Capistranoによるdeploy後にsitemapを再生成する

Posted at

sitemap_generatorというgemを使うと、RailsアプリケーションのXML Sitemapを簡単に出力することができる。

sitemap_generatorはCapistranoにも対応していて、deploy後に自動的にsitemapを再生成することが可能。

方法は簡単。deploy.rbに以下を記述すればOK。

after "deploy", "refresh_sitemaps"
task :refresh_sitemaps do
  run "cd #{latest_release} && RAILS_ENV=#{rails_env} bundle exec rake sitemap:refresh"
end

ドキュメントではbundle execがない記述が紹介されてるけど、こちらのほうが安全。

10
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?