Ad

Shopify Liquid Objects Not Showing Data

- 1 answer

I'm having trouble with Shopify objects not bringing data. Example below:

I've added the following object to my header so that I can attempt to detect which page the user is on and then assign different header styles per page:

{{ page.url }}

Using the page object:

https://help.shopify.com/themes/liquid/objects/page

This doesn't show anything on any pages:

No Data

Here's a bigger look at this area of code if required:

Code View

Is anybody able to help me understand my error here? Thanks so much.

Ad

Answer

Shopify have a few different types of pages:

  • Pages
  • Collections
  • Products
  • Blogs
  • Articles
  • Index
  • 404
  • Search
  • Cart
  • Account

When you try to say {{ page.url }} this takes only URL's of pages that includes pages in their URL. For example on pages/about-us you will get the URL of that page, but on a page collections/all you won't get the URL since that is a different type of page, there you will use {{ collection.url }} instead.

The page object is valid only on the page type.

You can see all the objects here: https://help.shopify.com/themes/liquid/objects

Ad
source: stackoverflow.com
Ad