コミュニティアチーブメントバーを展開する。

Submissions are now open for the 2026 Adobe Experience Maker Awards.

Mark Solution

この会話は、活動がないためロックされています。新しい投稿を作成してください。

解決済み

Getting host name using HTL

Avatar

Level 7

Hi Team,

 

I want to get the host name according to environments such as author , publisher and despatcher.

So I tried using java script like below.

window.location.hostname;

but my code is inside base page component. So it is saying window is not defined. Is there any way we can get the host name using HTL ?

 

Thanks in advance.

1 受け入れられたソリューション

Avatar

正解者
Community Advisor

Hi @JakeCham 

You can get server details in sightly from request object as below.

<div>The Scheme (http/https) is ${request.scheme}</div>
<div>The hostname(domain) is ${request.serverName}</div>
<div>The port is ${request.serverPort}</div>
<div>The request URI is ${request.requestURI}</div>

Regards

Shiv

 

Shiv Prakash

元の投稿で解決策を見る

3 返信

Avatar

正解者
Community Advisor

Hi @JakeCham 

You can get server details in sightly from request object as below.

<div>The Scheme (http/https) is ${request.scheme}</div>
<div>The hostname(domain) is ${request.serverName}</div>
<div>The port is ${request.serverPort}</div>
<div>The request URI is ${request.requestURI}</div>

Regards

Shiv

 

Shiv Prakash

Avatar

Level 7

Thanks a lot!! 

Avatar

Community Advisor

@JakeCham , although @Shiv_Prakash_Patel 's response is perfectly fine for your query.

If you are trying to create an absolute URL or externalLink. Try using Exernalizer service in your Sling Model (which can be tied to a runmode config) and then get it in sightly. 
Externalizing URLs | Adobe Experience Manager
Externalizer (The Adobe AEM Quickstart and Web Application.)