Custom code in head and body tags

Add custom code and scripts that apply to your entire site or individual pages.

This video features an old UI. Updated version coming soon!

If you have a paid Webflow account or if your project has an active site plan, you can add custom code and scripts that apply to your entire site or individual pages. This can be useful for adding additional HTML, CSS, and JavaScript.

In this lesson:

  1. Supported code
  2. Custom code in Project settings
  3. Custom code in Page settings

Supported code

The code sections only support HTMLCSS, and JS. You can't integrate server-side languages (such as Perl, PHP, Python, or Ruby) in any code section.

Tags

If the embeddable code has opening and/or closing tags, make sure to add them to make the code work.

Link tag: <link>

The <link> tag defines a link between a document and an external resource and always goes in the <head> element.</head>

Meta tag: <meta>

The <meta> tag provides metadata about your site and always goes in the <head> code</head> section.

Style tags: <style> </style>

The <style> tag</style> defines CSS styles in your site and always goes in the <head> code</head>.

Script tags: <script> </script>

The <script> tag</script> allows you to embed Javascript in your site and can go in the <head> or </head>. However, adding your <script></script> tags just before the closing tag (footer code) will ensure that your webpages load all content before the JavaScript is processed. This helps with page load speed and provides a better user experience. Custom scripts will only appear on the published site. 

Important: As of March 1st, 2018, newly published Webflow sites include the latest version of jQuery (v3.3.1). Previously, Webflow sites were published using jQuery v2.2.0.

Resource: Embedding javascripts [↗]

Important: Adding <html>, <body>, or <head> tags in the embed will break your website/layout.</head></body></html>

Why can't I add long code?

Custom code in each section cannot be longer than 10,000 characters. If the code you want to place on your site is longer, you can store it on another server and then embed it as a script file.

Custom code in Project settings

Important: Adding external <script> tags to the <head> of your project can slow page loads. Consider adding the "async" or "defer" attribute in the <script> tag to improve performance.</script>

Head code

Code that is entered in the Head tag is applied to your entire site and is a way to link external resources, add meta data, and use custom styles in your document. In Project settings >Custom code, enter your code in the Head code section, and Save changes.

‍Insert code before the closing head tag of your Webflow project

Resource: HTML Head element [↗]

Footer code

Code that is entered in the Body tag is applied to your entire site and is a way to add things like scripts to your site. In Project settings > Custom code, enter your code in the Footer code section, and Save changes.

Insert code before the closing body tag of your Webflow project
Custom scripts will only appear on the published site.

Custom code in your Page settings

The code included in the custom code section of any page will only apply to that page, and will appear after any site-wide custom code.

Inside < head > tag

From inside the Designer, open Page settings, enter your code in the Head code section, and Save the settings. See which tags go in the <head> tag</head>.

‍Insert code inside the < head > tag of a page

Before < / body > tag

From inside the Designer, open Page settings, enter your code in the Body code section, and Save the settings. Usually <scripts></scripts> go in this section.

‍Insert code before the < / body > tag of a page
Custom scripts will only appear on the published site.
Try Webflow — it's free
No items found.
This video features an old UI. Updated version coming soon!