Expand my Community achievements bar.

SOLVED

dumb question: how to create a page with custom HTML

Avatar

Level 9

I have been writing slingservlets to do backend functions, and testing with postman.

However, sometimes I need to create a test HTML page, e.g. with a form to upload a file.

In aem its easy to create pages, but you can only add text/images, you cant edit the HTML.

Looking in the project, I cant see an obvious way to create a HTML page.  Any suggestions where to look?

There are a lot of tutorials on creating pages from templates, but these dont seem to include editing HTML.  Presumably I need to write some code to create a new template with my HTML, then create a page to use that template.  I cant see how to create a template where I can defined the HTML the template uses?  

 

Or do I instead have to create a new component with a simple HTML form in it, then drop that into an existing page template?

 

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@TB3dock,

For your use case, custom HTML for local development environment & test purposes, I would suggest you create a simple component. Next, ensure your component is within a component group, so you can drag and drop the component on the page. 

Once when you have created your simple AEM component, you can go ahead and edit your existing page. Drag the component into the page. If your available component is not listed in the components sidebar, then you might want to double-check if your template policies (editable template), or allowed components (static template).

If you want to write HTML into your webpage the quick and dirty way, then you can also make changes directly into your basepage.html, where HTML will be visible on your entire local development environment. 

View solution in original post

3 Replies

Avatar

Correct answer by
Community Advisor

@TB3dock,

For your use case, custom HTML for local development environment & test purposes, I would suggest you create a simple component. Next, ensure your component is within a component group, so you can drag and drop the component on the page. 

Once when you have created your simple AEM component, you can go ahead and edit your existing page. Drag the component into the page. If your available component is not listed in the components sidebar, then you might want to double-check if your template policies (editable template), or allowed components (static template).

If you want to write HTML into your webpage the quick and dirty way, then you can also make changes directly into your basepage.html, where HTML will be visible on your entire local development environment. 

Avatar

Level 9

Thanks for this. so components are easier to figure out how to write than page templates. Regarding the basepage.html, where would I find this?  in the crx editor, I see /apps/mysite/components/page which has body.html.  However, I dont think this is used anywhere. If I create a new page on our site, the only page template available is "SPA Template", which i cant find.

Avatar

Community Advisor
Stick to components for your basic testing requirements. In the scenario of finding your basepage.html, you must first look at your cq:Page/jcr:content node, find the sling:resourceType, and then sling:superResourceType.