Welcome to the Liquify Community

Updated 3 months ago

Create custom theme setting for code in head

At a glance
The community member wanted to create a global theme setting for custom code in the <head> tag in Webflow, but when they added the Liquid code, it was moved into the <body> tag instead. They tried various solutions, including using <div><div></div></div>, but the issue persisted. The community members discussed that raw text is not allowed in the <head> tag, and the Webflow team is working on a solution where they can use <script>LIQUID CODE</script> to include Liquid code in the <head>. The community members also discussed using <li-settings:global> to define theme settings that would appear in the Shopify theme settings, including a favicon setting.
I wanted to create a global theme setting for custom code in the <head> tag and got the setting in Shopify by manually editing the settings_schema.json file in Github. To get it to work I want to add {% if settings.custom_head_code != blank %}{{ settings.custom_head_code }}{% endif %} in the global head code in Webflow (so it is included in all layout files). But when I do that, the text is moved into the <body> and inside of a <p> tag instead. I suspect that this is something that Liquify is doing, since it looks correct in the Webflow code export.

Is there a way I can keep this as pure Liquid code directly in my <head> tag when doing the Liquify conversion?
Attachments
code_in_body.png
webflow_global_head.png
Skrmbillede_2024-09-17_kl._13.39.14.png
Skrmbillede_2024-09-17_kl._13.39.04.png
r
j
G
27 comments
Bonus: is there a way to define the theme settings in settings_schema.json through Liquify, or is it fine to do that manually in Github. It doesn't look like it will conflict when I update the theme, so I assumed that it was ok πŸ€”
Hi @riziki, can you try adding this into your head: <div li-if="settings.custom_head_code != blank"><div li-object="settings.custom_head_code"></div></div>

That could fix the problem quickly
but thats a strange behaviour
can you send me the exported file ?
Thank you @jonas.halbstark ! I've attached the export here. Another thing I also noticed, is that it also causes the li-page="page-name" attribute to be removed from the <body> tag on the affected pages.

I just tried what you suggested with the li-if attributes on <div>, and it was still moved into the body. I'd prefer another method than li-object, since it would wrap the code in a div which isn't great inside the <head> tag.
Attachments
Skrmbillede_2024-09-18_kl._13.21.53.png
Skrmbillede_2024-09-18_kl._13.21.27.png
If I add the Liquid tags inside an HTML comment, they get through as expected though.
Attachments
Skrmbillede_2024-09-18_kl._13.30.04.png
Skrmbillede_2024-09-18_kl._13.30.10.png
Thats strange. We are looking into it.
Thanks! It could be some kind of validation reformatting. If I publish the Webflow site with {% if settings.custom_head_code != blank %}{{ settings.custom_head_code }}{% endif %} in the global head code in, it's also moved automatically into the <body> on the webflow.io site probably because raw text is not allowed in the <head> tag πŸ€”
Attachments
Skrmbillede_2024-09-18_kl._16.50.59.png
Skrmbillede_2024-09-18_kl._16.50.53.png
yes. these elements are not allowed in the head. We are working on a solution where you can use <script li-liquid >LIQUID CODE</script>. Thanks for your patience
Hi @riziki, we are currently working on two solutions.
  1. is <script li-liquid >LIQUID CODE</script>
  2. is li-settings:global where you can add plain settings json to the global settings. Works like li-settings:custom
Curretnly in testing. I will give you feedback as soon as possible
Awesome! Sounds like these should solve what I'm looking for πŸ™Œ
Hi @riziki, you can try this feature now πŸ™‚ just add <script li-liquid >LIQUID CODE</script> this in your head
Hey @jonas.halbstark, I was just looking for a solution and found this.

Is it possible to use this to set up a global setting that would appear in the theme settings in Shopify?
I'd like to set up a place for a website favicon this way, as many online tutorials point to this part of the settings for changing the favicon and my client got confused not finding it there.

Is it possible to do or are favicons carried over from Webflow rn? Thanks!
yes that can be used. We are currently testing a new element li-settings:global where you can write theme settings. That helps a lot. Then you can do settings for favicon and a lot more
How do I bind the setting to the favicon though, as it's auto-generated in the <head> in the Webflow code?
You can paste this into the settings schema:
[ { "name": "General Settings", "settings": [ { "type": "image_picker", "id": "favicon", "label": "Favicon Image", "info": "Will be scaled down to 32x32px" }, { "type": "image_picker", "id": "apple_touch_icon", "label": "Apple touch icon image", "info": "Will be scaled down to 120x120px" } ] } ]
Yeah, that's clear - but how do I bind it to the favicon declaration? My understanding that you take the Webflow's head code and use it in the theme, right? So I can add another <link rel="shortcut icon"> in the header, making a duplicate?
its already in the head code.. so you should be able to use it already
@jonas.halbstark , could you please clarify how li-settings:global works?

I've added it in the following way but it doesn't seem to be picked up:
Thanks!
Attachment
image.png
@jonas.halbstark - thanks!
Hi @Georgy Rakita, thats still in testing and not live πŸ™‚
Ah sorry, re-reading your previous messages and I see that you never said it's live - sorry again!
No worries, adding it manually works anyways!
Add a reply
Sign up and join the conversation on Discord
. Thanks for your patience","dateCreated":"2024-09-19T15:55:31.983Z","dateModified":"2024-09-19T15:55:31.983Z","author":{"@type":"Person","url":"https://liquify.hall.community/members/9198b265-c813-4ed7-89ba-4025d177dc62","name":"jonas.halbstark","identifier":"9198b265-c813-4ed7-89ba-4025d177dc62","image":"https://cdn.discordapp.com/avatars/947621552478904320/9741d807d28f33e26a3a3b01c121c60f.webp?size=256"},"commentCount":0,"comment":[],"position":11,"upvoteCount":0},{"@type":"Comment","text":"Hi @riziki, we are currently working on two solutions. is is li-settings:global where you can add plain settings json to the global settings. Works like li-settings:customCurretnly in testing. I will give you feedback as soon as possible","dateCreated":"2024-09-25T15:00:28.053Z","dateModified":"2024-09-25T15:00:28.053Z","author":{"@type":"Person","url":"https://liquify.hall.community/members/9198b265-c813-4ed7-89ba-4025d177dc62","name":"jonas.halbstark","identifier":"9198b265-c813-4ed7-89ba-4025d177dc62","image":"https://cdn.discordapp.com/avatars/947621552478904320/9741d807d28f33e26a3a3b01c121c60f.webp?size=256"},"commentCount":0,"comment":[],"position":12,"upvoteCount":0},{"@type":"Comment","text":"Awesome! Sounds like these should solve what I'm looking for πŸ™Œ","dateCreated":"2024-10-14T11:14:05.037Z","dateModified":"2024-10-14T11:14:05.037Z","author":{"@type":"Person","url":"https://liquify.hall.community/members/d688d3c1-5316-4b7e-9c97-d72c7185edbd","name":"riziki","identifier":"d688d3c1-5316-4b7e-9c97-d72c7185edbd","image":"https://cdn.discordapp.com/avatars/498220888773099527/7a3619af4049f5bc6a07e1fae0cb8906.webp?size=256"},"commentCount":0,"comment":[],"position":13,"upvoteCount":0},{"@type":"Comment","text":"Hi @riziki, you can try this feature now πŸ™‚ just add this in your head","dateCreated":"2024-10-16T06:29:47.903Z","dateModified":"2024-10-16T06:29:47.903Z","author":{"@type":"Person","url":"https://liquify.hall.community/members/9198b265-c813-4ed7-89ba-4025d177dc62","name":"jonas.halbstark","identifier":"9198b265-c813-4ed7-89ba-4025d177dc62","image":"https://cdn.discordapp.com/avatars/947621552478904320/9741d807d28f33e26a3a3b01c121c60f.webp?size=256"},"commentCount":0,"comment":[],"position":14,"upvoteCount":0},{"@type":"Comment","text":"Hey @jonas.halbstark, I was just looking for a solution and found this.Is it possible to use this to set up a global setting that would appear in the theme settings in Shopify? I'd like to set up a place for a website favicon this way, as many online tutorials point to this part of the settings for changing the favicon and my client got confused not finding it there.Is it possible to do or are favicons carried over from Webflow rn? Thanks!","dateCreated":"2024-11-07T17:08:06.959Z","dateModified":"2024-11-07T17:08:06.959Z","author":{"@type":"Person","url":"https://liquify.hall.community/members/a795ae56-31a7-4bb3-be0d-b96af1df71a3","name":"Georgy Rakita","identifier":"a795ae56-31a7-4bb3-be0d-b96af1df71a3","image":"https://cdn.discordapp.com/avatars/285408769154744330/86c30acf081932328fc277c0391fd435.webp?size=256"},"commentCount":0,"comment":[],"position":15,"upvoteCount":0},{"@type":"Comment","text":"yes that can be used. We are currently testing a new element li-settings:global where you can write theme settings. That helps a lot. Then you can do settings for favicon and a lot more","dateCreated":"2024-11-07T17:40:06.132Z","dateModified":"2024-11-07T17:40:06.132Z","author":{"@type":"Person","url":"https://liquify.hall.community/members/9198b265-c813-4ed7-89ba-4025d177dc62","name":"jonas.halbstark","identifier":"9198b265-c813-4ed7-89ba-4025d177dc62","image":"https://cdn.discordapp.com/avatars/947621552478904320/9741d807d28f33e26a3a3b01c121c60f.webp?size=256"},"commentCount":0,"comment":[],"position":16,"upvoteCount":0},{"@type":"Comment","text":"How do I bind the setting to the favicon though, as it's auto-generated in the in the Webflow code?","dateCreated":"2024-11-07T17:41:42.732Z","dateModified":"2024-11-07T17:41:42.732Z","author":{"@type":"Person","url":"https://liquify.hall.community/members/a795ae56-31a7-4bb3-be0d-b96af1df71a3","name":"Georgy Rakita","identifier":"a795ae56-31a7-4bb3-be0d-b96af1df71a3","image":"https://cdn.discordapp.com/avatars/285408769154744330/86c30acf081932328fc277c0391fd435.webp?size=256"},"commentCount":0,"comment":[],"position":17,"upvoteCount":0},{"@type":"Comment","text":"You can paste this into the settings schema:[ { \"name\": \"General Settings\", \"settings\": [ { \"type\": \"image_picker\", \"id\": \"favicon\", \"label\": \"Favicon Image\", \"info\": \"Will be scaled down to 32x32px\" }, { \"type\": \"image_picker\", \"id\": \"apple_touch_icon\", \"label\": \"Apple touch icon image\", \"info\": \"Will be scaled down to 120x120px\" } ] } ]","dateCreated":"2024-11-07T20:38:44.386Z","dateModified":"2024-11-07T20:38:44.386Z","author":{"@type":"Person","url":"https://liquify.hall.community/members/9198b265-c813-4ed7-89ba-4025d177dc62","name":"jonas.halbstark","identifier":"9198b265-c813-4ed7-89ba-4025d177dc62","image":"https://cdn.discordapp.com/avatars/947621552478904320/9741d807d28f33e26a3a3b01c121c60f.webp?size=256"},"commentCount":0,"comment":[],"position":18,"upvoteCount":0},{"@type":"Comment","text":"Yeah, that's clear - but how do I bind it to the favicon declaration? My understanding that you take the Webflow's head code and use it in the theme, right? So I can add another in the header, making a duplicate?","dateCreated":"2024-11-08T13:52:52.427Z","dateModified":"2024-11-08T13:52:52.427Z","author":{"@type":"Person","url":"https://liquify.hall.community/members/a795ae56-31a7-4bb3-be0d-b96af1df71a3","name":"Georgy Rakita","identifier":"a795ae56-31a7-4bb3-be0d-b96af1df71a3","image":"https://cdn.discordapp.com/avatars/285408769154744330/86c30acf081932328fc277c0391fd435.webp?size=256"},"commentCount":0,"comment":[],"position":19,"upvoteCount":0},{"@type":"Comment","text":"its already in the head code.. so you should be able to use it already","dateCreated":"2024-11-08T13:54:54.324Z","dateModified":"2024-11-08T13:54:54.324Z","author":{"@type":"Person","url":"https://liquify.hall.community/members/9198b265-c813-4ed7-89ba-4025d177dc62","name":"jonas.halbstark","identifier":"9198b265-c813-4ed7-89ba-4025d177dc62","image":"https://cdn.discordapp.com/avatars/947621552478904320/9741d807d28f33e26a3a3b01c121c60f.webp?size=256"},"commentCount":0,"comment":[],"position":20,"upvoteCount":0},{"@type":"Comment","text":"Ah okay, thanks!!","dateCreated":"2024-11-08T13:55:42.623Z","dateModified":"2024-11-08T13:55:42.623Z","author":{"@type":"Person","url":"https://liquify.hall.community/members/a795ae56-31a7-4bb3-be0d-b96af1df71a3","name":"Georgy Rakita","identifier":"a795ae56-31a7-4bb3-be0d-b96af1df71a3","image":"https://cdn.discordapp.com/avatars/285408769154744330/86c30acf081932328fc277c0391fd435.webp?size=256"},"commentCount":0,"comment":[],"position":21,"upvoteCount":0},{"@type":"Comment","text":"@jonas.halbstark , could you please clarify how li-settings:global works?I've added it in the following way but it doesn't seem to be picked up:Thanks!","dateCreated":"2024-11-09T02:14:50.845Z","dateModified":"2024-11-09T02:14:50.845Z","author":{"@type":"Person","url":"https://liquify.hall.community/members/a795ae56-31a7-4bb3-be0d-b96af1df71a3","name":"Georgy Rakita","identifier":"a795ae56-31a7-4bb3-be0d-b96af1df71a3","image":"https://cdn.discordapp.com/avatars/285408769154744330/86c30acf081932328fc277c0391fd435.webp?size=256"},"commentCount":0,"comment":[],"position":22,"upvoteCount":0},{"@type":"Comment","text":"@jonas.halbstark - thanks!","dateCreated":"2024-11-12T20:52:10.465Z","dateModified":"2024-11-12T20:52:10.465Z","author":{"@type":"Person","url":"https://liquify.hall.community/members/a795ae56-31a7-4bb3-be0d-b96af1df71a3","name":"Georgy Rakita","identifier":"a795ae56-31a7-4bb3-be0d-b96af1df71a3","image":"https://cdn.discordapp.com/avatars/285408769154744330/86c30acf081932328fc277c0391fd435.webp?size=256"},"commentCount":0,"comment":[],"position":23,"upvoteCount":0},{"@type":"Comment","text":"Hi @Georgy Rakita, thats still in testing and not live πŸ™‚","dateCreated":"2024-11-12T21:04:53.598Z","dateModified":"2024-11-12T21:04:53.598Z","author":{"@type":"Person","url":"https://liquify.hall.community/members/9198b265-c813-4ed7-89ba-4025d177dc62","name":"jonas.halbstark","identifier":"9198b265-c813-4ed7-89ba-4025d177dc62","image":"https://cdn.discordapp.com/avatars/947621552478904320/9741d807d28f33e26a3a3b01c121c60f.webp?size=256"},"commentCount":0,"comment":[],"position":24,"upvoteCount":0},{"@type":"Comment","text":"Ah sorry, re-reading your previous messages and I see that you never said it's live - sorry again!","dateCreated":"2024-11-12T21:05:45.211Z","dateModified":"2024-11-12T21:05:45.211Z","author":{"@type":"Person","url":"https://liquify.hall.community/members/a795ae56-31a7-4bb3-be0d-b96af1df71a3","name":"Georgy Rakita","identifier":"a795ae56-31a7-4bb3-be0d-b96af1df71a3","image":"https://cdn.discordapp.com/avatars/285408769154744330/86c30acf081932328fc277c0391fd435.webp?size=256"},"commentCount":0,"comment":[],"position":25,"upvoteCount":0},{"@type":"Comment","text":"yes sorry","dateCreated":"2024-11-12T21:07:07.269Z","dateModified":"2024-11-12T21:07:07.269Z","author":{"@type":"Person","url":"https://liquify.hall.community/members/9198b265-c813-4ed7-89ba-4025d177dc62","name":"jonas.halbstark","identifier":"9198b265-c813-4ed7-89ba-4025d177dc62","image":"https://cdn.discordapp.com/avatars/947621552478904320/9741d807d28f33e26a3a3b01c121c60f.webp?size=256"},"commentCount":0,"comment":[],"position":26,"upvoteCount":0},{"@type":"Comment","text":"No worries, adding it manually works anyways!","dateCreated":"2024-11-12T21:11:19.476Z","dateModified":"2024-11-12T21:12:03.859Z","author":{"@type":"Person","url":"https://liquify.hall.community/members/a795ae56-31a7-4bb3-be0d-b96af1df71a3","name":"Georgy Rakita","identifier":"a795ae56-31a7-4bb3-be0d-b96af1df71a3","image":"https://cdn.discordapp.com/avatars/285408769154744330/86c30acf081932328fc277c0391fd435.webp?size=256"},"commentCount":0,"comment":[],"position":27,"upvoteCount":0}],"author":{"@type":"Person","url":"https://liquify.hall.community/members/d688d3c1-5316-4b7e-9c97-d72c7185edbd","name":"riziki","identifier":"d688d3c1-5316-4b7e-9c97-d72c7185edbd","image":"https://cdn.discordapp.com/avatars/498220888773099527/7a3619af4049f5bc6a07e1fae0cb8906.webp?size=256"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0}}]