web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / Microsoft Portals/Powe...
Power Pages
Unanswered

Microsoft Portals/Power Pages Auto Formatting Web Page Content

(0) ShareShare
ReportReport
Posted on by

I've been working with Microsoft Portals (now rebranded as Power Pages) for over a year. During this time, one issue continues to emerge that will break my web pages. At random times, something on the back end will try to reformat my liquid scripts and sometimes my JavaScript.

 

For example, I will add a liquid script if tag in the middle of my JavaScript (perfectly acceptable) and it will work. A couple hours later, I'll view the page in the Power Pages editor, click sync, and view the page in my browser to see the page doesn't load properly and there are errors reported in the console. When I check back, I see that my liquid script was completely reformatted like what is seen below.

 

Example of what it looked like originally

 

<script>
...
{% if liquidVariable = "someValue" %}
...
{% endif %}
</script>

 

 

Example of how it gets auto formatted

 

<script>
...
{
%
if liquidVariable = "someValue"
%
}
...
{
%
endif
%
}
</script>

 

 

In addition, it appears the web pages do not like self closing tags on HTML elements as the "auto-formatter" (or whatever is causing these issues) will try to replace the self closing tag with a manual tag (though it always puts it in the incorrect spot).

Example: 

 

<img />

 

will be automatically changed to

 

<img></img>

 

 

If anyone knows the cause of these "auto-formats" and how to disable it, I would greatly appreciate any additional information.

Categories:
  • Pinosmil Profile Picture
    21 on at

    Hi Kyle,

    from where are you trying to implement your code? Power Pages Design studio.

    This autoformatting will not happen if you modify the code directly on Web Templates, Custom JS on the Basic or Advance Forms. Try to access Web Templates and Basic and Advance forms from the Portal Management Model Driven app and implement your code directly from there. Info about Portal Management app https://learn.microsoft.com/en-us/power-apps/maker/portals/configure/configure-portal 

  • KyleSchroeder Profile Picture
    on at

    Hi.  I've implemented my scripts in multiple locations; web templates, content snippets, and page local content.  Due to how the site and pages are designed, I can't limit my code to only web templates and on the basic/advanced forms. I typically do all my development in the portal management model-driven app or in a 3rd party tool called XRMToolBox.  I avoid content development in the Portal/Power Pages editor as it will always autoformat the content. XRMToolBox is the safest way to write all my code/scripts, however other developers and the client may not choose to only use this tool.  Also, I've noticed the autoformatting occurring randomly even if I only open the XRMToolBox and Portal Management model-driven app.  As a result, if anyone tries to edit the local page content from the Power Pages editor or the Portal Management model-driven app, the autoformat may be triggered and break the page.

  • Yoonsik Profile Picture
    2 on at

    Have you tried adding "Site/EnableDefaultHtmlEncoding" in site settings for your website?

    For me it helped adding this and setting to false. 

     

    Reference: https://learn.microsoft.com/en-us/power-pages/configure/configure-site-settings

  • KyleSchroeder Profile Picture
    on at

    Thanks for sharing, however site settings only affect the end-user experience and not the developer experience.  The issue I mentioned has to do with working inside the Portal Management Model-Driven app and making changes to content snippets, web templates, and local content for web pages.

  • TomB91 Profile Picture
    4 on at
    Hi Kyle,
     
    Have you had any luck in preventing this from happening. It's causing me issues as well. If seems to occur for me when someone opens a webpage from the portal design studio using the browser VS Code option.
     
    The reformatting that happens breaks all sorts of things on the page, the main one being fetchXML in liquid. Very frustrating.
     
    Regards,
     
    Tom

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Pages

#1
M Bilal Khan Profile Picture

M Bilal Khan 114

#2
sannavajjala87 Profile Picture

sannavajjala87 30 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 24

Last 30 days Overall leaderboard