Sling:alias vs vanityUrl in AEM
Asked Answered
B

1

7

what is the main difference between vanity url and sling:alias?

as per docs : here

sling:alias – The property may be set on any resource to indicate an alias name for the resource. For example the resource /content/visitors may have the sling:alias property set to besucher allowing the resource to be addressed in an URL as /content/besucher.

Vanity URL - You define Vanity URLs in CQ to create easy-to-remember and easy-to-search URLs on your website.

But still I can not sure what exactly is the difference and when do we use them. Please help me out in this.

Bambi answered 22/3, 2016 at 6:11 Comment(0)
R
14

I think that the main difference is that with sling:alias you may set just other name where the resource is available (note name, but not path) and with sling:vanityPath you define absolute virtual path to access this resource. So for example if you have the following structure:

content
└── visitors(sling:alias=besucher, sling:vanityPath=/besucher)
    └── area(sling:alias=bereich)
        ├── a(sling:vanityPath=/bereich/a)
        └── b(sling:alias=c,sling:vanityPath=/bereich/b)

You can access the above pages also in the following ways:

/content/besucher.html -> /content/visitors
/content/besucher/area.html -> /content/visitors/area
/content/besucher/bereich.html -> /content/visitors/area
/content/besucher/area/a.html -> /content/visitors/area/a
/content/besucher/area/b.html -> /content/visitors/area/b
/content/besucher/bereich/a.html -> /content/visitors/area/a
/content/besucher/bereich/b.html -> /content/visitors/area/b
/content/besucher/bereich/c.html -> /content/visitors/area/b
/besucher -> /content/visitors
/bereich/a -> /content/visitors/area/a
/bereich/b -> /content/visitors/area/b
Riccio answered 22/3, 2016 at 11:46 Comment(2)
beat me to it, was just starting to write an answer as well. I think this explains it nicely.Peterson
Thanks for your response. Now, I got the idea about it.Bambi

© 2022 - 2024 — McMap. All rights reserved.