Customizing the Shop
Last updated
Last updated
About
Team© 2024 Sylius. All Rights Reserved
Sylius stands out from other eCommerce platforms not only because of its vibrant community and clean codebase but also due to its exceptional developer experience. Its flexibility and ease of customization allow you to adapt the platform to meet your unique business needs.
Let’s explore how you can leverage these features to make a simple yet important customization: replacing the default Sylius logo with your store’s custom logo.
The default Sylius templates are clean and elegant, but you might want to make your store unique by customizing it with your brand’s logo. Here’s how you can replace the default Sylius logo:
Copy your logo file to the following directory:
Next, you need to import the logo in the entry.js
file located at:
Add the following line to import the logo:
After making this change, run the following command to rebuild the assets:
Now, let’s create the template that is responsible for displaying the logo. All templates are supposed to be managed and organized in the /templates
directory. Your new template might look like this:
Ensure the second argument in the asset()
function is correct for the app context. For more details, check the Managing Assets page.
Sylius Twig Hooks is a completely new concept introduced in Sylius 2.0. You can find dedicated documentation on this topic here.
Sylius 2.0 introduces Twig Hooks for customization. First, use the browser’s developer console to identify the element you want to change. For the logo, the relevant block is:
In our case, the following block is relevant:
In summary, a hook is a specific location within the template where you can attach or override custom content. A hookable refers to the individual element (such as a template or component) that is linked to the hook. You can assign multiple hookables to a single hook, allowing for flexible customization.
Since we want to override the logo, we need to reference our custom logo template in the appropriate hook and hookable configuration. A custom configuration for this might look like the following:
Place your custom logo template in the specified path. You can customize the directory structure, but following Sylius’ hierarchy is recommended for future consistency.
If you prefer not to use Twig Hooks, you can override the Sylius template directly, the old way.
Identify the Template: The original logo template is located at:
Override It: Create a new file with the same name in the following directory:
After following either method, your custom logo should now be displayed on your store.
Congratulations! You’ve successfully customized a Sylius template. Let’s take things a step further by introducing your business logic into the system.
For more information on customizing templates or Sylius template events, check out the Customizing Templates chapter and the Managing Assets documentation.