Have your say in Community Polls: What was/is your greatest motivation to start your own business?

Re: Product Page

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
Shopify Partner
101 11 11

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 %}

Please remember to Like & Mark Solution to the post if it helped you.
Thanks !
If you'd like to support me, you can Buy Me a Coffee
Need help with anything related to Frontend?
Checkout kevinkarma.me
Hoppop
Tourist
20 0 1

where to add this code

kevinkarma55
Shopify Partner
101 11 11

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

Please remember to Like & Mark Solution to the post if it helped you.
Thanks !
If you'd like to support me, you can Buy Me a Coffee
Need help with anything related to Frontend?
Checkout kevinkarma.me

Made4uo-Ribe
Shopify Partner
9069 2166 2673

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!

If this fixed your issue, Likes and Accept as Solution are highly appreciated. Coffee tips fuel my dedication.
Get experienced Shopify developers at affordable rates—visit Made4Uo.com for a quick quote!
Need THEME UPDATES but have custom codes? No worries, for an affordable price.
Create custom Shopify pages effortlessly with PageFly's drag-and-drop ⚙️.
Hoppop
Tourist
20 0 1

didnt worked

Made4uo-Ribe
Shopify Partner
9069 2166 2673

oh, what theme your using? 

If this fixed your issue, Likes and Accept as Solution are highly appreciated. Coffee tips fuel my dedication.
Get experienced Shopify developers at affordable rates—visit Made4Uo.com for a quick quote!
Need THEME UPDATES but have custom codes? No worries, for an affordable price.
Create custom Shopify pages effortlessly with PageFly's drag-and-drop ⚙️.