Tuesday, 30 September 2025

Mastering URL Shortening in AEM: Vanity URLs and Beyond

 What is URL shortening (or shorthand URL)?

A URL shortening (or shorthand URL) is a way to make a long, complicated web address shorter and easier to share. 

Instead of sharing a long URL like:

https://www.colibra.com/content/weretail/us/en/products/womens/shoes.html

We can create a short, friendly URL like:

https://www.colibra.com/shoes

We have three ways to do URL shortening/create shorthand URLs.
1.Vanity URL
2.Redirect/Rewrite Rule
3.etc Mapping

Here, we discussed how to implement URL shortening in AEM using Vanity URLs and how AEM handles this internally.

How we can add AEM vanity Url for a particular page



Step 1: Navigate to this URL and download vanity URL’s components package.


Step 2: Accept EULA terms and conditions and press download button highlighted red in color.



Step 3: Upload vanityurls-components package and install on publish instance:




 Step 4: To add a vanity URL for a specific field available in the page properties.

Go to the page and open its properties.
 

Step 5: Here, the Vanity URL property is a multi-field, which means you can apply multiple vanity URLs for this page.


Step 6: These vanity URLs are mapped as Sling mappings.
    

step 7: after that Save&Close.



Note:
  • The Vanity URL is based on the page, not the domain.
  • Vanity URLs work on both Author and Publish instances.
Step 8: Now access this page.





Step 9: If we want to publish this page, we must first replicate it.


Step 10: Page is accesible using Vanity Url on Publish.


Now, let's explore how AEM works internally.

Inside the JCR repository, our pages are present under /content.
For example,
/content/wknd/us/en/author-info/jcr:content.
Inside the page's jcr:content, the sling:VanityPath property is saved.





On the dispatcher/web server, this page cannot be accessed using the vanity URL.






No comments:

Post a Comment

Mastering URL Shortening in AEM: Vanity URLs and Beyond

 What is  URL shortening (or shorthand URL )? A URL shortening (or shorthand URL ) is a way to make a long, complicated web address short...