mercredi 3 août 2016

Sitemap.xml not working in Production

I am able to build the sitemap.xml in my dev environment, but on pushing it to production environment I keep getting this error.

XML Parsing Error: mismatched tag. Expected: </link>.
Location: http://ift.tt/2aPifaf
Line Number 68, Column 4: </head>       
---^

In controller I have it like this:

  def sitemap
    headers['Content-Type'] = 'application/xml'

    respond_to do |format|
      format.xml
    end
  end

The view is like this (sitemap.xml.builder):

xml.instruct! :xml, :version=>'1.0'
xml.tag! 'urlset', "xmlns" => "http://ift.tt/xwbjRF" do

  if Rails.env.production? 
    base_url = "https://#{request.host_with_port}"
  else
    base_url = "http://#{request.host_with_port}"
  end

  xml.tag! "link", rel: 'alternate', hreflang: "en", href: base_url

  xml.url do
   xml.loc base_url
   xml.lastmod "2015-01-01"
   xml.changefreq "yearly"
   xml.priority 1.0
  end  

 xml.url do
  xml.loc "#{base_url}/intro"
  xml.lastmod "2016-04-03"
  xml.changefreq "monthly"
  xml.priority 1.0
 end 

end

Aucun commentaire:

Enregistrer un commentaire