motleydev
motleydev

Reputation: 3447

Can't create a link to a page in Shopify

I am trying to create a single link (inside a snippit) that will link to any given page but I can't figure out how to do it. I am using this general structure:

{{ 'Link Text' | link_to: X }}

I don't know what the parameter for x should be to access page/product on my site. Appreciate any help.

Upvotes: 6

Views: 16700

Answers (1)

Zach Lysobey
Zach Lysobey

Reputation: 15724

From: wiki.shopify.com/Link_to (link now broken)

{{ 'Typo' | link_to: 'http://typo.leetsoft.com' }}

This should create a link that looks like:

<a href="http://typo.leetsoft.com">Typo</a>

More info on links in liquid here: http://wiki.shopify.com/Link

Update 1: You should also be able to use relative links:

{{ 'Typo' | link_to: 'pages/home' }} <!-- relative to current page -->
{{ 'Typo' | link_to: '/pages/home' }} <!-- relative to site root -->
{{ 'Typo' | link_to: '../pages/home' }} <!-- relative to parent dir -->

Update 2: Ore better yet, you can reference the page's handle: {{ 'Title' | pages.pagehandle.url }}

Upvotes: 14

Related Questions