I migrated a blog from Rails to Astro. Here's what I learned.

How Astro felt for me, as a Ruby developer.
Published 2023-10-13 4 min read
I migrated a blog from Rails to Astro. Here's what I learned.

Long story short - I’ve made the shift from Ruby on Rails to Astro for my blog, and the primary push came when my AWS free tier ran its course. With Rails being a dynamic framework, it requires a runtime, and let’s face it: running a static site is more economical and brisker than a Rails application. Astro seemed to be the right fit for this transition, and here I am, eager share my experience.

How I ended up with a blog in Rails?

My association with Ruby on Rails dates back to 2011. Back in the day, Rails was branded as an “opinionated framework”. But as seen it in many contexts, I realized it’s an incredibly adaptable tool, that can fit a lot of scenarios.

When the itch to start a personal blog began, I was torn between WordPress and building something from scratch. I dabbled with WordPress one evening, and to be frank, I found myself lost. It seemed laden with specifics I wasn’t keen on, and mastering them was essential for a streamlined, lightweight blog.

The JavaScript realm was next on my list. However, anything React-centric seemed excessive for a blog. The default sizable JS bundle that comes with it? Overwhelming and unnecessary. That immediately ruled out options like Next.js or Gatsby.

Hugo was another contender. But, navigating its documentation was not a pleasant experience. Really basic stuff was pretty clear, but when customizations were in question - not so much. A simple “hello-world” project later, I was disheartened and reluctant to proceed.

Fed up, I took matters into my own hands and decided that I would just write a small Ruby on Rails app. My mission? Craft a minimalistic blog, aiming for a stellar 100/100 on Google’s Lighthouse. And to be honest I succeded at that.

How I landed on Astro?

The expiration of my AWS free tier was the nudge I needed. With the prospect of shelling out $12 monthly for a t2.micro instance, I was at a crossroads. A cheaper VPS was an alternative, but it dawned on me: why host a blog as a dynamic site when the static route is more feasible?

Astro had been creating some buzz for a while, especially with its ability to produce static HTML, CSS, and minimal JS, that is actually needed. I wanted to learn more about it for a while and it was the perfect opportunity to use it.

How it went with Astro?

The proof is in the pudding, or in this case, the page you’re currently on – it’s powered by Astro.

Astro’s “Getting Started” tutorial is an absolute gem. You can initalize Astro projects with an example app - the very same one referred in the tutorial. It offers a hands-on experience, acquainting you with core Astro concepts such as pages, routing, collections, and layouts. It’s a solid foundation for anyone starting with the framework.

Astro’s guides and manuals are a strong point. They do a great job at breaking down the basics so anyone can understand. When you get to the more advanced topics, it might take a bit more time and thought to grasp everything. But most of the stuff is described one way or another, so you can puzzle things together and make them work.

Working with Astro is easy because of its quick updates, hot reloads are seamless. Clearly, Astro is made for websites and online content. The Astro team has carefully put together tools and extras to help with common website needs. This includes things like sitemaps, RSS feeds, and other useful features that people might not notice at first, but are important for websites.

My migration journey spanned over four short post-work sessions. Notably, one entire session was dedicated to image optimization and adapting my existing articles to the fresh format.

Do I recommend it?

In a heartbeat! For static websites, Astro gets my stamp of approval. I haven’t ventured into SSR territory with it yet, so my opinion may change in the future. Astro strikes a harmonious balance between simplicity and adaptability, making it a top pick for static sites. It’s really sensible compared to many other JS frameworks, it just gets the basics right.

#rubyonrails #astro #javascript