Skip to content
BlinkpageBlinkpageDocs

Custom code

Add your own JavaScript and CSS to the whole site or to one page with the Code Editor, and know when your code runs.

On this page

The Code Editor lets you add your own CSS and JavaScript to a project. You can apply code to every page or to a single page.

Warning: Custom code runs on your published site

Your code runs for every visitor, and broken code can break your pages. Test it in a preview before you publish.

#Open the Code Editor

  1. Open your project

    Open the project in the editor.

  2. Open the Code Editor

    In the top bar, click the Code Editor icon. The Code Editor panel opens.

  3. Pick a tab

    Click Global Javascript, Page Javascript, or Global CSS. The status bar shows your cursor position, the character count, and the language.

The Code Editor saves your code about one second after you stop typing. There is no save button. If a tab is greyed out, your role does not allow you to edit it. See Organizations, teams & roles.

The Code Editor with the Global CSS tab open.

#Add global CSS

Global CSS applies to every page of the project. It can override values you set in the Design tab.

  1. Open the Global CSS tab

    In the Code Editor panel, click Global CSS.

  2. Write your CSS

    Type your rules in the editor.

Global CSS
html {  scroll-behavior: smooth;}img {  max-width: 100%;  height: auto;}

#Add global JavaScript

Global JavaScript runs on every page of the project. Paste JavaScript only. Do not include <script> tags.

  1. Open the Global Javascript tab

    In the Code Editor panel, click Global Javascript.

  2. Write your code

    Type or paste your code. The sample opens links to other websites in a new tab.

Global Javascript
document.addEventListener("click", (event) => {  const link = event.target.closest("a[href^='http']");  if (link && link.hostname !== window.location.hostname) {    link.target = "_blank";    link.rel = "noopener noreferrer";  }});

#Add page JavaScript

Page JavaScript runs only on the page that is open in the editor. Use it for code that one page needs, such as a script for a single campaign page.

  1. Open the page

    In the editor, open the page that needs the code.

  2. Open the Page Javascript tab

    In the Code Editor panel, click Page Javascript.

  3. Write your code

    Type or paste your code. Each page keeps its own code.

#Test your code

  1. Open a preview

    Click the Preview icon in the top bar. The preview opens in a new tab and runs your custom code.

  2. Check the result

    Use the page as a visitor would. Open your browser's developer tools and look at the console for errors.

  3. Fix and repeat

    Change your code in the Code Editor, then reload the preview tab.

Your custom code is part of the site when you publish. See Preview & share links to share a preview before you publish.

#Next steps

Edit this page(opens in a new tab)