本文用於學習記錄用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.如今查看前端頁面,打完收工。