Link to

From Shopify Wiki

Jump to: navigation, search

link_to(link, url, title="")

A link_to filter creates a link (<a href="...>) for the given parameters. The first parameter is the linkname, the second where the link goes. A third parameter "title" is optional but not needed in most cases.

Example of a static link using the link_to filter:

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

More examples of how to use this filter:

<ul>
   {% for link in linklists.previous-deals.links %}
      <li>{{ link.title | link_to: link.url }}</li>
   {% endfor %}
</ul>

This would create a list of all links in the linklist "previous-deals".

If you want links to a certain vendor or product type, use the filters link_to_vendor and link_to_type instead.

To specify a title attribute, use the link_to filter like so:

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

It will generate the following HTML:

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