Skip to content

Instantly share code, notes, and snippets.

View joe-dempsey's full-sized avatar

joe dempsey joe-dempsey

View GitHub Profile
@joe-dempsey
joe-dempsey / shopify-sub.liquid
Last active March 19, 2024 21:51
Shopify menu with submenu
{% comment %} this is a barebones menu with submenu items for Shopify {% endcomment %}
{% comment %} see shopify docu for creating submenu items: https://help.shopify.com/manual/sell-online/online-store/menus-and-links#create-a-drop-down-menu {% endcomment %}
{% comment %} first assign the menu - this is the only thing you need to change {% endcomment %}
{% assign linklist = settings.collections_nav %}
{% comment %} in the above line change the collections_nav to the handle of your main naivgation {% endcomment %}
{% comment %} the code below will do the rest {% endcomment %}
@joe-dempsey
joe-dempsey / richsnippet.liquid
Last active December 14, 2023 08:27
Shopify product richsnippet - structured data markup for Shopify product templates
{% assign current_variant = product.selected_or_first_available_variant %}
<div id="richsnippet">
<div itemscope itemtype="http://schema.org/Product">
<meta itemprop="url" content="{{ shop.url }}{{ product.url }}">
<meta itemprop="image" content="{{ product.featured_image.src | img_url: 'grande' }}">
<meta itemprop="name" content="{{ product.title | escape }}">
<meta itemprop="description" content="{{ product.description | strip_html }}">
{% if product.vendor %}<meta itemprop="brand" content="{{ product.vendor }}">{% endif %}
@joe-dempsey
joe-dempsey / shopify image blog first available
Created June 27, 2018 12:32
shopify blog show first available image if no featured image
{% if article.image.size > 0 %}
# show featured image
{% else %}
{% if article.content contains "<img" %}
{% assign src = article.content | split: 'src="' %}
{% assign src = src[1] | split: '"' | first %}
<img src="{{ src }}" alt="{{ article.title }}">
{% endif %}
{% endif %}
@joe-dempsey
joe-dempsey / redirects-shopify.html
Created April 7, 2017 14:23
shopify straight to checkout/stay on page.
{% assign send_to_cart = true %}
{% assign send_to_checkout = false %}
{% for tag in product.tags %}
{% if tag contains "no__redirect" %}
{% assign send_to_cart = false %}
{% endif %}
{% if tag contains "send_to_checkout" %}
{% assign send_to_checkout = true %}
{% endif %}
@joe-dempsey
joe-dempsey / tagged-posts.liquid
Last active July 19, 2023 10:12
Use custom layout for tagged posts with Shopify.
{% comment %}
we need a way to loop through tags to display a different blog template for tagged posts as to the general overview/archive page
doesn't seem like there's an easy way to do this but there is.
there are tow options:
{% endcomment %}
{% if current_tags %}...{% else %}...{% endif %}
@joe-dempsey
joe-dempsey / add FAQ's in Shopify
Created October 9, 2017 12:49
FAQ's in shopify.
{% comment %}
add assets in head and trigger in footer
page.faq needs {% section 'faq' %}
below is that section content.
{% endcomment %}
<div class="ui accordion">
{% for block in section.blocks %}
@joe-dempsey
joe-dempsey / gist:3b8ecb06940c5d5ffb481432002ff01d
Created July 11, 2018 15:20
section half alternating blocks
<div data-section-id="{{ section.id }}" id="mysection_{{ section.id }}" class="richtext-custom-section contain-full-width no-padding ">
{% for block in section.blocks %}
{% capture thecycle %}{% cycle 'odd', 'even' %}{% endcapture %}
{% if thecycle == 'odd' %}
<div class="odd_block">
<div class="one-half-custom odd_img ">
{% if block.settings.custom_image %}
<img src="{{ block.settings.custom_image | img_url: '2048x' }}" />
{%endif%}
@joe-dempsey
joe-dempsey / gist:a3e18282c907f69d0d70efffe95ed31b
Created September 12, 2018 13:14
social meta shopify example
{%- assign og_title = page_title -%}
{%- assign og_url = canonical_url -%}
{%- assign og_type = 'website' -%}
{%- assign og_description = page_description | default: shop.description | default: shop.name -%}
{% comment %}
Template specific overides
{% endcomment %}
{%- if template.name == 'product' -%}
{%- assign og_title = product.title | strip_html -%}
@joe-dempsey
joe-dempsey / list-all-products.liquid
Created January 28, 2020 13:48
shopify list all products with image heights - to check validity of image assets on products
<article class="site-page page-{{ page.handle }}" data-template-page>
<header class="page-masthead">
<h1 class="page-title">
page displaying image sizes for all products
</h1>
</header>
<ul>
@joe-dempsey
joe-dempsey / cookies-consent-shopify-section
Created April 29, 2020 11:59
cookies consent on shopify section - quick