I have created one static page, I wanna load specific JS only on specific static page, Here my static page name is ship_custom_page If I have to load specific JS in product page so I am using catalog_product_view.xml but how can I load only for specific static page ? and I am using community Magento2.4.0 version so Magento removed update layout field from static page.

My custom cms page url key is custom-shipping-page

Here is my code

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <link src="Magento_Cms::js/map-file.js"/>

2 Answers 2


You can use Custom Layout Update section from Design tab in CMS page

  • Create cms_page_view_selectable_custom-shipping-page_AnyLayoutName.xml at

<theme_dir>/<Namespace>_<Module>/layout with your desired content.

for more information refer Dev docs

  • Select AnyLayoutName from drop down for Custom Layout Update in Admin for CMS page.

Hope above will help!


You can try creating a selectable layout as explained at https://devdocs.magento.com/guides/v2.4/frontend-dev-guide/layouts/xml-manage.html#create-cms-pageproductcategory-specific-selectable-layouts

Selectable layout updates can only be loaded from the global store theme and work only in the single website with single theme configurations. If a specific entity like cms-page/product/category has an individual theme applied in the design configuration tab, the selected theme will have priority over the selected layout update.

If selectable layout doesn't work for you for the above mentioned reason. Then you can try the following: Create custom page XML layout file within your custom module or theme:
Example :: cms_page_view_id_home.xml


  1. https://devdocs.magento.com/guides/v2.4/frontend-dev-guide/layouts/xml-manage.html
  2. https://devdocs.magento.com/guides/v2.4/frontend-dev-guide/layouts/layout-overview.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.