How to add Code Snippets to a Craft CMS website

Learn how to embed Common Ninja’s Code Snippets on your Craft CMS website without coding.

Create Snippets

loved by 500K+ businesses

widget-editor

In This Guide

In this quick guide, you'll learn how to embed the Code Snippets into your Craft CMS website by generating your embed code and adding it seamlessly to your website.

Embed Code Snippets on Craft CMS

01
Create a Code Snippets plugin for Craft CMS on Common Ninja
First, create a Craft CMS Code Snippets plugin on Common Ninja. On the plugins catalog, find the Code Snippets and enter the Editor.
Create a Code Snippets plugin for Craft CMS on Common Ninja
02
Save the Code Snippets plugin
When you're done creating the Code Snippets plugin, click on the Save Changes button at the right top corner of the editor. If you don't have an account on Common Ninja, you'll have to register first.
Save the Code Snippets plugin
03
Copy the Code Snippets Embed Code
When you're ready to add the Code Snippets plugin to your Craft CMS website, click the Add To Website button at the top bar of the Editor. On the window that opens, click the Copy Icon to copy the plugin embed code. In the next steps, you will paste this code into your Craft CMS website.
Copy the Code Snippets Embed Code
04
Paste the code to your Craft CMS website’s HTML field.
Next, go to your Craft CMS website editor and find the HTML field. It is most likely in the form of an HTML/Code widget or module which you can find on the Craft CMS’s editor. Add it to your page, and paste the Code Snippets Embed Code you’ve copied before to the HTML field. Save and update, and that’s it, you should have Common Ninja’s Code Snippets plugin on your Craft CMS website.
Paste the code to your Craft CMS website’s HTML field.
05
Alternative Method 1: Through the HTML option in the text’s editing area.
If you can't find the HTML/Code widget or module, there's another way to put Common Ninja’s Code Snippets plugin on your Craft CMS plugin. You can just add the code to a special HTML section in the text editor.
Alternative Method 1: Through the HTML option in the text’s editing area.
06
Alternative Method 2: Add it directly to your Craft CMS website’s HTML code.
If you're having trouble finding a widget or a special part in your text editor where you can add the Embed Code, you can try a different way to add the Code Snippets plugin to your Craft CMS website. You can do this by putting it straight into your Craft CMS website's HTML code.
Alternative Method 2: Add it directly to your Craft CMS website’s HTML code.

Why Use This Widget

Use the Code Snippets widget when your audience includes developers and you need to show examples that are readable and copy friendly. Proper formatting and syntax highlighting make code far easier to scan than plain text blocks. This matters for documentation, tutorials, API references, and technical blog posts. Visitors can quickly identify language constructs, keywords, and structure, which helps them implement solutions correctly. By presenting code in a clean, consistent style across your site, you send a signal of technical quality and care. You also reduce errors and support questions that arise from unclear or poorly formatted samples.

This tutorial was written by the Common Ninja product team, creators of interactive, no-code widgets for Craft CMS website. Common Ninja helps over 500,000 users build engaging online experiences without coding.