Custom templates and code

Learn how to build a custom code section in the WEMASY Website Builder with your own HTML, CSS and script, and keep its parts editable with shortcodes.

Custom templates are sections you write in code. Use them when the standard elements cannot make the design you need, for example an overlapping image grid or a special animation. You write the HTML, CSS and script yourself, and you can still leave text, images and buttons editable for later with shortcodes. This is an advanced feature for people who know HTML and CSS.

Add a code section to a page

Website Builder: Create a custom template

  1. Click the red plus between two sections on the canvas.
  2. In the Add a section window, open More options.
  3. Click Create template. Its description says it adds a custom code block you can edit freely.
  4. Select the new section to open its code editor at the bottom of the screen.
  5. Write your HTML, your script and your CSS in the three code fields.

Keep parts editable with shortcodes

Inside your HTML you can place WEMASY shortcodes, such as [wemasy-paragraph], [wemasy-image] and [wemasy-button]. They render as normal elements, so you or a colleague can later change the text or image on the canvas without touching the code. The list of shortcodes is in Shortcodes in Website Builder.

Use your style settings in CSS

Use the CSS variables of your site instead of fixed values, for example var(--headingsizes-h1) for the Heading 1 size or var(--color-default-text) for the default text color. Then your custom section follows the colors and sizes you set in Customization.

Script

The script field holds a component options object, starting with export default {}. Use it for behavior such as scroll effects or counters. Keep it small and test the page on mobile.

Saved templates with custom fields

  1. Click Templates in the left sidebar.
  2. Click Create Template.
  3. Under Custom Fields, click Create Custom Fields to build a form with the Form Builder.
  4. Save the template.

The fields you define become settings of the template. In code you refer to them by key, for example {{ acf.title }}. Structures use the same idea: see Advanced custom fields on structures.

Reuse a custom section

Hover over the section, open Advanced Options and click Convert to Template to save it for other pages, or Convert to Reusable Template to link it everywhere. See Reusable templates.

Tip: try the standard elements first. Sections built from elements are easier to change later, also for people who do not code.

Put it to work
on your own website.

Start free with WEMASY and build your site in a few minutes.