Sign In | Sign Up



amp

How to create Accelerated Mobile Page (AMP) in rails website

by Kevin

Accelerated Mobile Page (AMP) is a framework for creating a fast and light-weight mobile website.  There are not many ruby gems for creating AMP pages for the existing Rails website.    We find one like rails_amp. But it doesn't fit our needs. That's why we come up with our solution. It's a simple but powerful one. Here's how we create AMP pages for our Rails website.        Add custom Mime::Type  We add custom Mime at config/initializers/mime_types.rb       It's only one line code. The code registers amp as a new custom format for text/html. This way, we'll be able to handle this format on our controllers. This leads us to the next step.      Add amp format to the controller  There is no need to add this to all of the controllers. We only add it to one of the actions in the controller that serves the article pages.      Here's the explanation of that gist That format.amp will render the AMP pages when the user's browser requested it. So, when Google bots or your user's browser visits your AMP URL handled by that…
Score: 1.22
07/10/2020

Privacy settings changed!

Article is saved. Do you want to continue editing the article or leave and edit later?

Not logged in, Please login to continue

Location: United States (en)
  • United States (us)
  • 日本 (jp)
  • Indonesia (id)
  • India (in)
Terms and Conditions | Privacy Policy | About Us
FAQ | Contact Us
 
© 2025 123ish