Search code examples
aemslingvanity-url

Sling:alias vs vanityUrl in AEM


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.


Solution

  • 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