Effortless URL Handling in Roq with Qute super-power

Effortless URL Handling in Roq with Qute super-power

2024, Sep 16    

Managing URLs is now very easy! With our updated Qute-powered feature, you can now manage relative and absolute URLs with more flexibility, thanks to new methods for joining paths and handling absolute URLs. Let’s explore some examples.

How to Use It:

  • Relative URL Example (toString prints the relative url):
<a class="post-thumbnail" href="{post.url}"> </a>
  • Absolute URL Example:
<a class="post-thumbnail" href="{post.url.absolute}"> </a>
  • ** Smart URL:**
<meta name="twitter:image:src" content="{page.image.absolute}" >

There is a method in Page to retrieve the image url as a RoqUrl from the configured site images path. It is smart so that if the page image is external, it won't be affected.

Under the Hood: The Power of RoqUrl

At the core of this feature is the RoqUrl class that you can leverage from Qute, which makes joining and resolving URLs super easy. With this structure, joining paths is as simple as calling resolve(). This ensures your URLs are clean, predictable, and easy to manage—whether they’re relative or absolute.

Wrapping Up:

With Qute’s URL handling, you can now dynamically create and manage both relative and absolute URLs without any hassle. This new implementation will help keep your code clean while making it easier to navigate, link, and share content across your site.