How to add HTML to a page created using page api

i created a new page under Page doctype now i want to add html to it, how can i do it?

@Vinay1 If you have marked page as Standard = Yes, you can see .js, and .json file in your app

frappe-bench/apps/app_name/app_name/page/page_name where you can add .html and .py files for this and start coding

hi @Hardik_Gadesha I created a page called “loyalty_user_info” and it contains loyalty_user_info.js and loyalty_user_info.json by default and I added loyalty_user_info.html but when I view the page I can’t see the html view

here is the folder structure

contents of loyalty_user_info.html

here is the page view

if html is linked correctly then the page should look like this

@Vinay1

As per the example shown here anything external like a JS bundle or an HTML has to be included into the page using the Page API.

In my [custom_page_name].js (which is auto generated by Frappe) I added the following to render and include my HTML to be shown in the page

$(frappe.render_template("my_html_page")).appendTo(page.main);

The ‘my_html_page.html’ was put in the same directory where the Frappe generated page files are present and it loaded and rendered it in the page.

I think all the available methods in Page API should be documented so that it becomes easier to know what can be done.

1 Like