Shopify Liquid code examples

Build and customize themes faster with component-based Liquid examples

Show product SKU

Last updated: Feb 21, 2019


Stock keeping units (SKUs) are used to identify products and track inventory. You can display the unique SKU for a product and its variants on the product page.

  1. Add the following code to the product-template.liquid section, just below the product title.
  2. Depending on your theme, ensure that the SKU updates dynamically when you select other variants. If not, then you will need to add a few lines of JavaScript to your theme's JavaScript file.
{%- assign current_variant = product.selected_or_first_available_variant -%}
<span>{{ current_variant.sku }}</span>

Please note: We have intentionally limited CSS and JavaScript, and removed translation strings in order to keep these examples compatible with any theme. Any CSS we have included is for accessibility or rendering purposes.