I am creating a theme in Magento 2. So far I've figured out how to create a custom page layout for my homepage and how to style it with css. I'm moving on into adding JavaScript and more custom CSS, but I can't figure out how to do this for a specific page.
Every article and document I've come across mentions adding a script or link to the head using the defaults_head_blocks.xml
or default.xml
, which is great for something I need globally, but how would I add a script to the head of only one Page Layout?
For clarity and people new to this like me, this is my theme structure:
<theme_dir>/
- Magento_Theme/
- layout/
- default_head_blocks.xml (as far as I can tell no use in my situation)
- default.xml (nor this)
- page_layout/
- homepage.xml (my target page layout)
layouts.xml (defines my Homepage layout)
Theres more to my theme, but these are the relevant files.
Is there specific naming convention or xml attribute (within default.xml
) I can use if I want to configure homepage.xml
? How would I configure my homepage.xml
page layout?
EDIT My question is about targeting a specific page layout, this is not a question about coding homepages specifically, it's just an example using my current situation. For example, if I make a custom 'About' page, how do I figure out what xml file to override? (keywords 'figure out')
About Page
is a CMS page?CONTENT > Pages > choose a cms page > Design or Custom Design Update (2.1.x)
.