module PagesHelper
  def path_to_page(page)
    unless page.parent.nil?
      path_to_page(page.parent) + '/' + page.slug
    else
      root_url(trailing_slash: true) + page.slug
    end
  end
end

module PagesHelper
  def path_to_page(page)
    unless page.parent.nil?
      path_to_page(page.parent) + '/' + page.slug
    else
      root_url + '/' + page.slug
    end
  end
end

--- 
+++ 
@@ -3,7 +3,7 @@
     unless page.parent.nil?
       path_to_page(page.parent) + '/' + page.slug
     else
-      root_url + '/' + page.slug
+      root_url(trailing_slash: true) + page.slug
     end
   end
 end
Make root_url always have trailing slash