check if the page url contain specific text



In htl how can we check if the page URL contains specific text ?  ( intend to do it on the page rather than by Java )

${'a' in 'abc'} <!--/* returns true */-->  does not work  

Accepted Solutions (1)

Accepted Solutions (1)

Answers (1)

Answers (1)



Does not work in AEM 6.4 GA.

You can try using a small use js file and pass it the test string value as shown below:

Or go for Java.


use(function () {

    var testStr= this.value;

    var retValue = currentPage.path.toLowerCase().contains(testStr.toLowerCase());

    return {

        hasString: retValue



HTL Code:

<div data-sly-use.path="${'filepath.js' @ value='demo-page'}">



I have converted both strings to lower case for case insensitive check.