How to add custom icons in Gutenberg (without plugin)

Qara Yahya Avatar
How to add custom icons in Gutenberg without plugin

Hey WordPress enthusiasts! In today’s tutorial, we’re going to show you an easy way to add custom icons in Gutenberg—and the best part? You won’t need any plugins! Let’s dive in and make your Gutenberg experience even more versatile.

Here’s the thing, Gutenberg’s image block is more versatile than you might think. You can actually use it to add an icon by inserting a URL-encoded SVG. Sounds complicated? Don’t worry, we’re breaking it down for you.

Step 1: Get your SVG icon ready.

 Basicons
Google icons

Step 2: Convert SVG code to data URL.

1. Open the Yoksel’s URL Encoder website in your browser, and paste your SVG icon code in the “Insert SVG” box.

Yoksel's URL Encoder

2. The tool will automatically URL-encode your SVG. The URL-encoded SVG will appear in the “Ready for CSS” box.

3. Copy the image URL. To do this, select the code within the “Ready for CSS” field, but omit the brackets and quotation marks. The image URL is found between these brackets and quotation marks, as shown in the highlighted section of the image below.

Copy the image URL

Voila! You now have your URL-encoded SVG ready to use.

Step 3: Add Custom Icons in Gutenberg

Next, go to your WordPress site and either create a new post or edit an existing one. Insert a new Gutenberg image block, and instead of uploading an image, paste the URL-encoded SVG directly into the image link field.

Add Custom Icons in Gutenberg
Add Custom Icons in Gutenberg

And that’s it! You’ve successfully added an SVG icon as an image block in Gutenberg. This allows you to take advantage of all the features available in the image block, such as resizing the icon, setting its alignment, and more.

Here’s an example I quickly created using this tutorial:

Custom Icons in use
Custom Icons in use

Remember, creativity has no limits. There’s so much more you can do with Gutenberg blocks. Keep exploring and happy WordPress-ing!

Leave a Reply

Your email address will not be published. Required fields are marked *