How to add a Logout Button

Topic summary

A user seeks help adding a logout button (as an icon) to their Shopify store header that appears only when customers are logged in.

Proposed Solution:

  • Another user provided Liquid code using conditional logic ({% if customer %}) to display a logout link when users are authenticated and a login option otherwise.
  • The code snippet includes a logout link pointing to /account/logout.

Current Status:

  • The original poster is unsure where to insert the provided code within their theme files.
  • They’ve requested additional clarification and tagged another user for further assistance.
  • The issue remains unresolved and awaiting guidance on implementation location.
Summarized with AI on November 2. AI used: claude-sonnet-4-5-20250929.

Hi,

This is my website, https://the-triangle-club.myshopify.com. The password is hi1234. I want to add a logout button in the header (as an icon) once people have logged in. But, I am unsure how to do this. Please advise.

Best,

Chichi0114

Hi @chichi0114

Please use this code

{% if customer %}

Logout

{% else %}

Login CODE here

{% endif %}

If this solution is worked, then please Like this and Mark this as accepted solution!

Shuvam

Hi Laddisahsi, I was wondering where I should add that code. Thank you, Chichi0114

Hi @DaisyVo ,

Can you please help me with this too. Thank you so so much!

Best,

Chichi0114