You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

AEM中HTL渲染后<a>标签消失问题求助

Alright, let's tackle this issue where your HTL <a> tag is disappearing in AEM's publish view, leaving only plain text behind. I’ve dealt with similar headaches before, so here are the most common troubleshooting steps and fixes to try:

AEM’s Link Checker is often the culprit here. It validates links and can strip the entire <a> tag if it deems the link invalid (like if the target page isn’t published, or the URL format is flagged). Here’s how to check:

  • Head to the OSGi console (/system/console/configMgr) and look for the Link Checker Service
  • Look for settings like Remove Invalid Links—if this is enabled, try temporarily disabling it to see if the tag reappears
  • Double-check that the page at ${properties.targetURL} is actually published on your publish instance. Unpublished pages will get flagged as invalid links.

2. Fix HTL Context Safety for Text Content

You added @context='uri' to the href attribute, but the text portion of your link (${properties.targetURL}) doesn’t have a specified context. This can trigger AEM’s XSS protection to filter the entire tag. Update your HTL code to explicitly set the text context:

<div class="col-lg-6">
  <a href="${properties.targetURL@context='uri'}" class="black_transparent_button">
    View all fishes|${properties.targetURL@context='text'}
  </a>
</div>

Adding @context='text' tells HTL to treat that value as plain text, preventing unnecessary XSS filtering that might remove the entire link tag.

3. Verify Editable Template Component Policies

If you’re using an Editable Template, the component policy might be restricting allowed HTML tags:

  • Open the Template Editor and navigate to the component’s policy settings
  • Look for a section like "Allowed HTML Tags" and confirm <a> is included in the list
  • If it’s missing, add <a> to the allowed tags, then republish the template and your page.

4. Ensure Content Sync Between Author and Publish

Sometimes the issue is just a content sync problem between your author and publish instances:

  • Republish both your component (under /apps/your-component-path) and the page containing it
  • Use CRXDE Lite to compare the component’s HTL code on both instances—make sure they’re identical
  • Check if any OSGi configurations related to HTL or security are different between author and publish.

Start with steps 1 and 2 first—those are the most frequent causes of this exact issue. Let me know if any of these fix it!

内容的提问来源于stack exchange,提问作者mrjayviper

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 06:45:29