Skip to content

fix: Add --preferPlainHtml flag#2724

Closed
swetabar wants to merge 5 commits into
adobe:mainfrom
swetabar:feat/prefer-plain-html
Closed

fix: Add --preferPlainHtml flag#2724
swetabar wants to merge 5 commits into
adobe:mainfrom
swetabar:feat/prefer-plain-html

Conversation

@swetabar
Copy link
Copy Markdown
Contributor

Add an opt-in --prefer-plain-html flag to aem up so .plain.html wins over .html sibling in --html-folder mode

Related Issues

https://github.com/Adobe-AEM-Foundation/aem-experience-catalyst/issues/1129

Comment thread src/server/HelixServer.js Outdated
// Try .plain.html
const plainHtmlFile = path.resolve(
// Try second extension
const secondFile = path.resolve(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rather than first/second have you considered an approach where an arbitrary length array of options is allowed? (if it helps simplify, otherwise probably not worth it)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, create a helper function that resolves the local file and iterate over the candiates.

@tripodsan
Copy link
Copy Markdown
Contributor

@davidnuescheler @kptdobe why is there a fallback to .plain.html at all?

@kptdobe
Copy link
Copy Markdown
Contributor

kptdobe commented May 13, 2026

Because you approved it - see #2631
@karlpauls introduced it, not super clear why.

@alexcarol
Copy link
Copy Markdown
Contributor

alexcarol commented May 13, 2026

In experience modernization agent we're generating .plain.html that are both used to show the user a "preview" of their content and then get uploaded to DA once the user is satisfied. Considering the new "aem content" approach it might make sense to look at going "back" to generating .md files, but for now we're still using ".plain.html", so it makes sense to have a way to have a way to "prioritize them".

@tripodsan
Copy link
Copy Markdown
Contributor

Because you approved it - see #2631 @karlpauls introduced it, not super clear why.

@karlpauls I'm not sure anymore why we need to serve the .plain.html files on non plain requests...

@karlpauls
Copy link
Copy Markdown
Contributor

karlpauls commented May 19, 2026

The goal was to serve local content as it would come from the edge.

Originally, the html folder feature only served full HTML files (including a <head>) - just without the .html extension. This required authors and agents to produce complete HTML documents locally, which is cumbersome, and made updating the <head> painful since every file would need to be regenerated.

With #2631, we added support for serving a plain.html file, matching what .page/index.plain.html would return from the edge. This is simpler to produce and allows the head to be injected/managed separately.

For backwards compatibility, a .html file takes precedence over a .plain.html file. Additionally, no injection is applied to .html files - injection only happens for .plain.html.

Comment thread src/server/HelixServer.js Outdated
// Try .plain.html
const plainHtmlFile = path.resolve(
// Try second extension
const secondFile = path.resolve(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, create a helper function that resolves the local file and iterate over the candiates.

Comment thread src/server/HelixServer.js Outdated
Comment on lines +210 to +211
* @param {string} relativePath path relative to HTML folder (without extension)
* @param {string} ext extension to append (e.g. '.html', '.plain.html')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the relativePath / ext separation is not important to this function, so I would only use 1 argument: relativePath and concat them in the caller.

Comment thread src/server/HelixServer.js Outdated
Comment on lines +243 to +245
if (relativePath.includes('/../')) {
return null;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is also checked in the validatePathSecurity above... so no need to check here,

Copy link
Copy Markdown
Contributor

@tripodsan tripodsan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks. I'll merge it asap

@tripodsan
Copy link
Copy Markdown
Contributor

merged with #2728

@tripodsan tripodsan closed this May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants