I am using sitemap_generator gem to generate sitemap for my rails application. I have generated sitemap for most of the part including youtube videos.

Now I added social icons like facebook, twitter, linkedin, and youtube in the footer with each of them linking to their respective social network profile. Like following

<div class="social">
     <link href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet">

     <a target="_blank" href="facebook_url"><i class="fa fa-facebook-square fa-3x social"></i></a>
     <a target="_blank" href="twitter_url"><i class="fa fa-twitter-square fa-3x social"></i></a>
     <a target="_blank" href="linkedin_url"><i class="fa fa-linkedin fa-3x social"></i></a>
     <a target="_blank" href="google-plus"><i class="fa fa-google-plus-square fa-3x social"></i></a>
     <a target="_blank" href="youtube_url"><i class="fa fa-youtube-square fa-3x social"></i></a>
</div> 

How can I write a method in sitemap.rb file inorder to include these social media links in site map?

1

There are 1 best solutions below

2
Alexander Luna On

You can add links manually:

SitemapGenerator::Sitemap.create do
  add '/facebook_url'
  #etc.
end

You can specify a different host on a per link basis.

The documentation says it:

:default_host - String. Required. Host including protocol to use when building a link to add to your sitemap. For example http://example.com. Calling add '/home' would then generate the URL http://example.com/home and add that to the sitemap. You can pass a :host option in your call to add to override this value on a per-link basis. For example calling add '/home', :host => 'https://example.com' would generate the URL https://example.com/home, for that link only. For example:

https://www.facebook.com/ccsdscsc

add '/ccsdscsc', :host => 'https://facebook.com'

ccsdscsc in this case would be the path to your facebook profile. You would do the same for your other social media links.