Roq: Leveraging Quarkus to Build Static Sites at the Speed of Go
#DevOps

Roq: Leveraging Quarkus to Build Static Sites at the Speed of Go

Python Reporter
8 min read

Roq is a new static site generator built on top of Quarkus that combines Java's robustness with the speed of Go, offering developers a fast and efficient way to generate static websites.

Roq: Leveraging Quarkus to Build Static Sites at the Speed of Go

In the ever-evolving landscape of web development, static site generators have gained popularity for their performance, security, and simplicity. Enter Roq, a new player in this space that leverages the power of Quarkus to deliver static site generation with impressive speed and efficiency.

What is Roq?

Roq is a static site generator built on top of Quarkus, the popular Java framework renowned for its performance and developer experience. As Andy Damevin, a Quarkus core team member at IBM and creator of Roq, explains, "Roq is a static site generator that allows you to create static sites using Quarkus behind the scene, but you don't need to know about Quarkus or Java. It's just that it's using its power to do it."

Why Java and Quarkus?

The choice of Java and Quarkus for a static site generator might seem unconventional given the dominance of languages like Go and Rust in this space. However, Damevin sees compelling reasons for this approach:

"Java evolved into a much more developer-friendly programming language. Beyond the evolution of the language itself, Quarkus and its focus on developer experience also play a big role," Damevin explains. "I always love Java. I always preferred coding in Java rather than in Go, because it gives a really nice format to things. Everything is clean, you have tests, it's well organized."

The key differentiator is Quarkus' ability to compile to native binaries, addressing the traditional criticism of Java being slow:

"People were moving away from [Java] and starting using Go and stuff like that, mostly because it can compile to binaries. And if you take Java, you were not about to do that. And the JVM was a problem. And now it's starting to be a good thing again because when you see that you can do binary again, then you start to switch back to the JVM again because you say, 'Okay, I can do binary'. I can be quick, but I can also do optimization at runtime and things like that you can do with the JVM that you can do with Play Native."

How Roq Works

Roq's architecture is elegantly simple: a thin layer on top of Quarkus that translates markdown or AsciiDoc files into static HTML pages. What makes Roq unique is its approach to static generation:

"In Quarkus, you have two distinct parts of the built-in and the runtime. When you're building a static website, you want to build your website and building mean generating all those pages statically. When you think about Quarkus, you have the build time. So you want to build things at build time, but I thought, okay, why do we need to build things at build time? We could actually work like on any normal Quarkus application that is served at runtime and generate it like a snapshot. You just dump everything as files from the Quarkus application."

This approach allows Roq to leverage Quarkus' efficient runtime while maintaining the benefits of static site generation:

"It's just starting a Quarkus application, but it's so light that it's really fast and it's dumping everything from your Quarkus application to static files. This is what makes it pretty unique because you're actually using Quarkus like the Quarkus runtime. You're starting it to generate your things. And that's also what's cool for development because when you're developing compared to other static site generator, we don't actually generate anything. We just use Quarkus server. It will just render on demand. So you have live reload by default and when you actually need to grid, then we are going to dump everything as files."

Migrating to Roq

For those looking to migrate existing sites to Roq, the process is straightforward:

"To migrate an existing web deployment to Roq, it suffices to extract the content into markdown files and to add them to Roq," Damevin explains. "If you want to convert from WordPress to Roq, considering that you can easily convert from HTML to Markdown or to AsciiDoc, you would have to take your DB as HTML and convert it to Markdown. It doesn't mean that you need to write article in Markdown because you have a lot of editors that allows you to just use it like you would do on Word on any other writing tool, and then it will just convert it to Markdown."

The structure for a Roq site involves organizing content files and templates:

"When you have all your Markdown, there is a structure that you put your files in, and instead of having a DB, you will put them on a file system. And when you have all your file, you will need templates that direct how your page look like, and that's pretty much it. For styling, you use a Quarkus extension, which is named the web bundler. It will take all your JavaScripts, all your styles, bundle them to make them production ready, and make them available to your application and without any configuration."

Performance and Footprint

One of the key advantages of Roq is its small footprint and fast bootstrapping:

"In general, Roq's footprint and bootstrapping are quite fast. This comes from two factors: Quarkus' efficiency and the light nature of the extension," Damevin notes. "The engine is specialized. So you could also say that those parts are quite light."

This efficiency means Roq-generated sites can run on minimal infrastructure:

"You have the generating part where you generate all the pages and out of that, you get all the pages that you can run on any static server. So you could start it on Nginx or Apache or whatever. It's just static files. So it will work on Raspberry, I suppose."

Developer Experience

Roq is designed with both developers and content creators in mind:

"When you are a developer, you will use Quarkus to develop the base of the website. If you are a writer, you can use Quarkus and the file system to edit content. You can just do it on the file system. We are building a CMS as part of the UI. So as a writer, you will be able to just create edit like you would do on WordPress with what you see and what you get and everything."

Future Improvements

The Roq team is working on several enhancements to improve the platform:

  1. Better user experience for non-technical users: "We are building a small wrapper so that anyone can start developing of writing without having anything on this machine, which I think it's pretty cool. I don't think there are any other SSG in which you can do that."

  2. Enhanced styling capabilities: "I'm working on the V2 and the V2 has out of the box super for Tailwind. I know a lot of people want Tailwind or such UI frameworks to style their website. It's really important for static site generators. So it's coming and it will be soon there."

  3. AI integration: "We are thinking about AI in two places actually. One will be the CMS that will be in the WA where you will be able to write article. It will automatically add tags or guess the title or write part of the article or tell you suggestion about your article, stuff like that. So you can have AI help you edit content. And the other part where we are considering AI is because everyone is talking about AI now and it's important, but we will always need to have content on the web. If you don't have the content, the AI will not be able to build its data and without its data, it won't be able to work."

  4. AI-friendly metadata: "We are actually working also on that so that when you use Roq, it will automatically generate all the metadata that is necessary for AI to consume. Semantic graph, it will be AI friendly for AIs to consume."

Quarkus Ecosystem

As part of the Quarkus ecosystem, Roq benefits from the framework's strong community and development. Quarkus has moved to Commonhaus, ensuring its future as an open-source project:

"The fact that Quarkus has moved to Commonhaus, which is the most important part, it means that it's fully open source and led by an open source organization. And it doesn't mean that Red Hat and IBM will stop helping it, but I have not much information on that part, but they're also still building projects on top of it. So it means that they will rely on it in the future."

Getting Started with Roq

For those interested in trying Roq, the project is gaining traction in the Java community. Its combination of Java's robustness, Quarkus' performance, and the simplicity of static site generation makes it an attractive option for various use cases, from blogs to documentation sites to marketing pages.

As the static site generator landscape continues to evolve, Roq represents an interesting approach that bridges the gap between traditional Java development and modern web performance requirements. With its focus on developer experience and upcoming enhancements for non-technical users, Roq is positioned to make static site generation accessible to a broader audience while maintaining the technical excellence expected from the Quarkus ecosystem.

For more information about Roq, you can explore the Quarkus ecosystem and keep an eye on the project's development as it continues to evolve.

Comments

Loading comments...