本文用于学习记录用php
1.主题建立是在路径 /app/design/frontend/公司名/主题名称/css
我本身建立的路径为 app/design/frontend/Bman/castle,如下操做都在这个目录下前端
2.建立好本身的目录后,须要在castle主题目录下建立registration.php文件web
<?php
//用于注册主题
\Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::THEME, 'frontend/Bman/castle', __DIR__ );
3.而后再castle主题目录下建立theme.xml文件缓存
<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd"> <title> Castle Theme</title> <parent>Magento/luma</parent> </theme>
在此说明,magento开发都是须要继承父主题,而后进行覆盖开发。因为是学习,我这里继承的是Magento/luma默认主题app
4.在核心代码路径 app/vendor/magento/theme-frontend-luma/Magento_Theme/layout/default.xml文件中能够搜索到logo的block。frontend
若是本身的主题中存在和父主题同样的路径,本身的主题覆盖父主题的代码。因此咱们在本身的路径下建立以下:学习
castle/Magento_Theme/layout/default.xmlspa
<?xml version="1.0"?> <page layout="empty" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <body> <referenceBlock name="logo"> <arguments> <argument name="logo_file" xsi:type="string">images/logo.jpg</argument> <argument name="logo_alt" xsi:type="string">Custom Design</argument> <argument name="logo_img_width" xsi:type="number">250</argument> <argument name="logo_img_height" xsi:type="number">30</argument> </arguments> </referenceBlock> <referenceBlock name="copyright" remove="true"/> </body> </page>
上边代码我修改了logo,而且删除了copyright。记得图片放到路径为castle/Magento_Theme/web/images/logo.jpg, web文件夹是用来放css,js,图片的。code
5.最重要的一点就是在后台,content/configuation/ 路径下,应用本身的主题
6.记得刷新缓存 bin/magento c:c
7.如今查看前端页面,打完收工。