request
Information about the current URL and the associated page.
Properties
Returns
trueif the request is being made from within the theme editor. Returnsfalseif not.You can use
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.CautionYou shouldn't use
to change customer-facing functionality. The theme editor preview should match what the merchant's customers see on the live store.- locale
The locale of the request.
The protocol and host of the request.
ExampleCreate a context-aware absolute URLYou can use
request.originwith 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 }}Code
{{ product.selected_variant.url | default: product.url | prepend: request.origin }}Data
{ "product": { "selected_variant": null, "url": "/products/health-potion" }, "request": { "origin": "https://polinas-potent-potions.myshopify.com" } }Output
https://polinas-potent-potions.myshopify.com/products/health-potionOutput
https://polinas-potent-potions.myshopify.com/products/health-potionThe 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.
NoteIf the current path is for a page that doesn't exist, then
nilis returned.Returns
trueif the request is being made from within the theme editor's visual section preview. Returnsfalseif not.You can use
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.
Example
{
"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
}