Skip to main content

request

Information about the current URL and the associated page.

Properties

Returns true if the request is being made from within the theme editor. Returns false if not.

You can use request.design_mode to control theme behavior depending on whether the theme is being viewed in the editor. For example, you can prevent session data from being tracked by tracking scripts in the theme editor.

Caution

You shouldn't use request.design_mode to change customer-facing functionality. The theme editor preview should match what the merchant's customers see on the live store.

The domain that the request is hosted on.

The locale of the request.

The protocol and host of the request.

Example
Create a context-aware absolute URL

You can use request.origin with any object, object property, or filter that returns a relative URL to build a context-aware absolute URL.

{{ product.selected_variant.url | default: product.url | prepend: request.origin }}

Output

https://polinas-potent-potions.myshopify.com/products/health-potion
Anchor to
page_type
string from a set of values

The type of page being requested.

Possible values
404
article
blog
captcha
cart
collection
list-collections
customers/account
customers/activate_account
customers/addresses
customers/login
customers/order
customers/register
customers/reset_password
gift_card
index
metaobject
page
password
policy
product
search

The path of the request.

Note

If the current path is for a page that doesn't exist, then nil is returned.

Anchor to
visual_preview_mode

Returns true if the request is being made from within the theme editor's visual section preview. Returns false if not.

You can use request.visual_preview_mode to control theme behavior depending on whether the theme is being viewed in the editor's visual section preview. For example, you can remove any scripts that interefere with how the section is displayed.

{
"design_mode": false,
"host": "polinas-potent-potions.myshopify.com",
"locale": {},
"origin": "https://polinas-potent-potions.myshopify.com",
"page_type": "index",
"path": "/",
"visual_preview_mode": false
}
Was this section helpful?