| Work | Research and Development (R&D) | Growth | Data and Analytics | How to setup Google Search Console on a Rails app
How to setup Google Search Console on a Rails app

Overview

In this guide we'll walk through how to setup Google Search Console on your Rails application.

Visit Google Webmaster

Visit Google Webmaster and add your domain.

Submit Your Sitemap

To make it easy to submit a sitemap, we'll use the rails gem sitemap_generator

Open Gemfile, add and bundle install.

gem 'sitemap_generator', '~> 6.0'

Create file myapp/config/sitemap.rb

# Set the host name for URL creation
SitemapGenerator::Sitemap.default_host = "https://myapp.com"

SitemapGenerator::Sitemap.create(
  :default_host => 'https://myapp.com',
  :compress => false
  ) do
  # Put links creation logic here.
  #
  # The root path '/' and sitemap index file are added automatically for you.
  # Links are added to the Sitemap in the order they are specified.
  #
  # Usage: add(path, options={})
  #        (default options are used if you don't specify)
  #
  # Defaults: :priority => 0.5, :changefreq => 'weekly',
  #           :lastmod => Time.now, :host => default_host
  #
  # Examples:

  add "/login", :priority => 1, :changefreq => 'weekly'
  add "/signup", :priority => 1, :changefreq => 'weekly'
end