All coursesCustom code in Webflow
Try it: add page level code
We’re transitioning to a new UI, and are in the process of updating our Webflow University courses and videos.

Try it: add page level code

Add real, working code at the page-level

Try it: add page level code

Add real, working code at the page-level

Try it: Page-level code (page banner)

Next, you’ll add a small banner on a single page. You might use something like this for a page-specific announcement, campaign notice, or temporary message.

You don’t need a finished site for this. A blank or nearly blank project works just fine. The goal is to get hands-on and see custom code in action on a real site.

Step 1: Choose a page

Pick any page in your site. This can be the same page you used in the previous activity.

Step 2: Open Page settings

  1. Open the Page settings for your chosen page.
  2. Scroll to the Custom code section.

Step 3: Paste the script

Paste the code below into the Before </body> tag field:

<script>
  const notice = document.createElement("div");
  notice.textContent = "✨ Page-level custom code is working here.";
  notice.style.cssText = `
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 14px;
    background: #146EF5;
    color: #FFFFFF;
    font-size: 14px;
    border-radius: 8px;
    z-index: 9999;
  `;
  document.body.appendChild(notice);
</script>

Save the page settings.

Step 4: Preview or publish to staging

Enter Preview mode and make sure Enable custom code is toggled on. Or, publish your site to staging, then open the page in your browser. Staging is a safe testing environment, so this won’t affect your live site.

You’ll know this worked if:

You see a blue banner at the top of your selected page only.

Page-level banner visible on a single page of a Webflow site.

Extras:

  • Try changing the message text (content within the banner).
  • Try changing the banner style by adjusting the CSS properties for color, font-size, or border-radius.

You got this.

Now that you've got page-level code down, explore site-level code in the next activity.

No items found.

1

Getting started

Getting started
Getting started
Coming soon

1

Background & preview
5:00
Background & preview
Coming soon

1

Where you can add custom code
5:00
Where you can add custom code
Coming soon

2

Adding custom code

Adding custom code
Adding custom code
Coming soon

2

The Code Embed element
5:59
The Code Embed element
Coming soon

2

At the layout level (Code Embed element)
4:00
At the layout level (Code Embed element)
Coming soon

2

Page & site level code
3:36
Page & site level code
Coming soon

2

Page-level code
5:00
Page-level code
Coming soon

2

Site-level code
5:00
Site-level code
Coming soon

2

Custom code and the Webflow CMS
5:00
Custom code and the Webflow CMS
Coming soon

3

Managing custom code

Managing custom code
Managing custom code
Coming soon

3

Previewing, testing, & troubleshooting
5:00
Previewing, testing, & troubleshooting
Coming soon

3

Best practices for maintainable code
5:00
Best practices for maintainable code
Coming soon

4

Wrap up

Wrap up
Wrap up
Coming soon

4

Try it: Add custom code
3:00
Try it: Add custom code
Coming soon

4

Wrap up

Try it: add page level code
3:00
Try it: add page level code
Coming soon

4

Wrap up

Try it: add site-level code
3:00
Try it: add site-level code
Coming soon

4

Additional resources
4:00
Additional resources
Coming soon

Course progress

0%

Assessment

Up next

Try it: add site-level code

Test real, working code at the site-level
Complete & continue
Complete course