How can I edit only the product page without affecting the home page?

Hoppop
Tourist
20 0 1

how do i edit product page only whenever i remove header from product page it get removed from home page also i want to remove this custom liquid from products pages but when i do it gets removed from home page also help please

NorthOwl_1-1704894794695.png

 

Replies 6 (6)

kevinkarma55
Excursionist
30 1 6

Hi,

 

Headers are rendered in theme.liquid, which means they will be generated for every page, and removing them means removing them globally.

So you must only add the remove header code if it is the product page. You can use the following logic to know the product page:
//Inside <style>
{% if template contains 'product' %}

  //your code to remove header

{% endif %}

Skilled in building custom Shopify theme
Hoppop
Tourist
20 0 1

where to add this code

kevinkarma55
Excursionist
30 1 6

Go to main-product.liquid file and go to bottom of the page.

If you see style section which is indicated by <style> or <style type="type/css">, add above code inside it

If you don't see style section add following code at the bottom of the main-product.liquid file
<style type="type/css">

{% if template contains 'product' %}

  header {

  display: none;

}

{% endif %}


</style>

 

OR post your preview link so that I can see the code

Skilled in building custom Shopify theme

Made4uo-Ribe
Shopify Partner
5434 1307 1608

Hi @Hoppop 

From your Shopify admin dashboard, click on "Online Store" and then "Themes"

Find the theme that you want to edit and click on "Actions" and then "Edit code".

In the "theme. Liquid" file. Find the </body> tag and paste the code below before the tag. 

 

 {% if template == 'product' %}
<style>
/* place the css style here */
</style>
{% endif %}

 

And Save. 

Refresh the browser.

This code means it will apply the css style only in the product page.

 

 

Please don't forget to Like and Mark Solution to the post that helped you. Thanks!

Please don't forget to 

Like

 and 

Mark Solution 

to the post that helped you. Thanks!
Sip, savor, and support – your

Coffee Tip

 helps us keep coding magic.❤️❤️❤️
Need a knowledgeable developer? Come and visit us at

Made4uo.com


Hoppop
Tourist
20 0 1

didnt worked

Made4uo-Ribe
Shopify Partner
5434 1307 1608

oh, what theme your using? 

Please don't forget to 

Like

 and 

Mark Solution 

to the post that helped you. Thanks!
Sip, savor, and support – your

Coffee Tip

 helps us keep coding magic.❤️❤️❤️
Need a knowledgeable developer? Come and visit us at

Made4uo.com