'How to add Shopify cart to Hugo Ecommerce site

I have created a Static e-commerce site using Hugo.

Hugo ecommerce site

want to add products thro' Shopify admin, and get it reflected on my site.

I'm quite familiar with liquid templating. Kindly let me know how to achieve this?

So far,

  1. I have created a Shopify store, added a theme and added one product.
  2. I'm not looking to customize an existing theme, but completely remove that theme add my website theme in it.


Solution 1:[1]

You should be able to get your products using the Shopify API. This endpoint could be the one for you. From Hugo, you can then retrieve the products by getJson function with telling it the Shopify authorization header X-Shopify-Access-Token. Like this:

{{ $data := getJSON "https://your-store.myshopify.com/admin/api/2022-01/products.json" (dict "X-Shopify-Access-Token" "your-token") }}
{{ range $data }}
    {{ . }}
{{ end }}

Just make sure that you've replaced both the your-store and your-token strings.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1