{"id":24846,"date":"2019-10-30T12:15:19","date_gmt":"2019-10-30T10:15:19","guid":{"rendered":"http:\/\/www.webcodegeeks.com\/?p=24846"},"modified":"2019-10-29T13:50:24","modified_gmt":"2019-10-29T11:50:24","slug":"create-a-minimal-custom-gutenberg-block-in-wordpress","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/wordpress\/create-a-minimal-custom-gutenberg-block-in-wordpress\/","title":{"rendered":"Create a Minimal Custom Gutenberg Block in WordPress"},"content":{"rendered":"\n<p>I\u2019ve started playing with the new Gutenberg editor in WordPress, and the experience is a lot more modern than the old TinyMCE editor that\u2019s been around for a good 15 years (and I\u2019ve had blogs for almost that long!).<\/p>\n\n\n\n<p>Instead of editing all the content of the post at once, the Gutenberg editor works with blocks of content that can be reordered, with a clean look similar to the Medium editor.<\/p>\n\n\n\n<p>WordPress comes with many blocks by default for standard elements such as list, button or image galleries (see&nbsp;<a href=\"https:\/\/gogutenberg.com\/blocks\/\">https:\/\/gogutenberg.com\/blocks\/<\/a>&nbsp;for all the blocks that comes built-in). You can also save blocks you\u2019ve used in a post to reuse them in other posts.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" width=\"300\" height=\"300\" src=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2019\/10\/GutenbergBlockCover-1-300x300.png\" alt=\"\" class=\"wp-image-24847\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2019\/10\/GutenbergBlockCover-1-300x300.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2019\/10\/GutenbergBlockCover-1-300x300-150x150.png 150w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2019\/10\/GutenbergBlockCover-1-300x300-70x70.png 70w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/figure><\/div>\n\n\n\n<p>For a really effective blogging workflow, you\u2019ll need to build new blocks to extent the functionalities of the editor. For another blog I own (<a href=\"https:\/\/robotsbench.com\/\">https:\/\/robotsbench.com\/<\/a>), I wanted to use the HTML &lt;aside&gt; tag that\u2019s not available in the default blocks so I could give it a specific style in my theme.<\/p>\n\n\n\n<p>It involved more code than I expected and there are many steps. A good surprise still, the majority of the code the plugin is in React (JavaScript) instead of the PHP scripts used for standard plugins. You\u2019ll still need a tiny bit of PHP to package it as a WordPress plugin, but it\u2019s mostly boilerplate that can be generated.<\/p>\n\n\n\n<p>This tutorial will walk you through the creation of plugin to use the &lt;aside&gt; tag. We\u2019ll see how to:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Setting up the right tools to get started.<\/li><li>Create the boilerplate for the plugin.<\/li><li>Add a rich text field to add content to the block.<\/li><li>Add CSS styles to the block.<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Setting up the Environment<\/h2>\n\n\n\n<p>Before we get started creating the plugin template, you\u2019ll need to install the following on your computer to follow along.<\/p>\n\n\n\n<p>You\u2019ll already have all of this if you\u2019re already developing in JavaScript and own a blog, but here is it for completeness\u2019 sake:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>A&nbsp;<strong>code editor&nbsp;<\/strong>to edit PHP, JavaScript and CSS files. Right now, my favorite is Visual Studio Code at&nbsp;<a href=\"https:\/\/code.visualstudio.com\/\">https:\/\/code.visualstudio.com\/<\/a>.<\/li><li><strong>npm version 5.3 or more&nbsp;<\/strong>to create the template, get the required dependencies and package the plugin at&nbsp;<a href=\"https:\/\/www.npmjs.com\/get-npm\">https:\/\/www.npmjs.com\/get-npm<\/a>.<\/li><li>A&nbsp;<strong>live or local installation of WordPress with the Gutenberg editor&nbsp;<\/strong>to test the plugin. The Gutenberg editor now comes enabled by default in WordPress. I used Local by Flywheel to do this.<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Generate an Empty Plugin Template<\/h2>\n\n\n\n<p>We are going to use a tool called&nbsp;<em>create-guten-block<\/em>&nbsp;(<a href=\"https:\/\/github.com\/ahmadawais\/create-guten-block\">https:\/\/github.com\/ahmadawais\/create-guten-block<\/a>) to create a template for our new plugin and upload it to your blog to test the whole process first. It will only contain a single block in this tutorial, but you could add all your custom blocks in a single plugin.<\/p>\n\n\n\n<p>In the command line, use the following command to generate a plugin named&nbsp;<em>cp-aside-gutenberg-block<\/em>.<\/p>\n\n\n\n<pre class=\"brush:php\">npx create-guten-block cp-aside-gutenberg-block\n<\/pre>\n\n\n\n<p>\n\nYour newly created plugin will be in a&nbsp;<em>cp-aside-gutenberg-block<\/em>&nbsp;subfolder of the current folder. To prepare your plugin to upload on your WordPress installation, navigate to the plugin folder and build it.\n\n<\/p>\n\n\n\n<pre class=\"brush:php\">cd cp-aside-gutenberg-block\nnpm run build\n<\/pre>\n\n\n\n<p>\n\nTo deploy the plugin, add the following files in the&nbsp;<em>cp-aside-gutenberg-block<\/em>&nbsp;folder to a .zip file:\n\n<\/p>\n\n\n\n<pre class=\"brush:php\">\\dist \n\\src\nplugin.php\n<\/pre>\n\n\n\n<p>You could include all the other files for the sake of having the complete source code of your plugin on your blog, but they won\u2019t be used by WordPress. If you do include them, ignore the&nbsp;<em>\\node_modules<\/em>&nbsp;folder: it\u2019s a pretty big folder and you can always download the content again using the&nbsp;<em>npm install&nbsp;<\/em>command if you need to recreate it.<\/p>\n\n\n\n<p>Deploy it like you would deploy any other plugin, using the&nbsp;<em>Plugins\/Add new&nbsp;<\/em>menu in WordPress and clicking the&nbsp;<em>Upload Plugin<\/em>&nbsp;button to select the .zip file you just created. Activate it and it should now be shown as active in your list of plugins.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img decoding=\"async\" src=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2019\/10\/installed-1024x66-1024x66.png\" alt=\"\" class=\"wp-image-24848\" width=\"768\" height=\"50\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2019\/10\/installed-1024x66.png 1024w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2019\/10\/installed-1024x66-300x19.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2019\/10\/installed-1024x66-768x50.png 768w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure><\/div>\n\n\n\n<p>\n\nFrom there on, the new block will appear in the list of blocks when you edit a post.\n\n<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" width=\"357\" height=\"406\" src=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2019\/10\/blocklist.png\" alt=\"\" class=\"wp-image-24849\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2019\/10\/blocklist.png 357w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2019\/10\/blocklist-264x300.png 264w\" sizes=\"(max-width: 357px) 100vw, 357px\" \/><\/figure><\/div>\n\n\n\n<p>\n\nThe block can be rendered differently in the editor and in the final blog post. With the boilerplate, it will show up in the editor as the following:\n\n<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" width=\"793\" height=\"255\" src=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2019\/10\/backend.png\" alt=\"\" class=\"wp-image-24850\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2019\/10\/backend.png 793w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2019\/10\/backend-300x96.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2019\/10\/backend-768x247.png 768w\" sizes=\"(max-width: 793px) 100vw, 793px\" \/><\/figure><\/div>\n\n\n\n<p>\n\nAnd in the real post (or in the post preview):\n\n<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" width=\"746\" height=\"241\" src=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2019\/10\/frontend.png\" alt=\"\" class=\"wp-image-24851\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2019\/10\/frontend.png 746w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2019\/10\/frontend-300x97.png 300w\" sizes=\"(max-width: 746px) 100vw, 746px\" \/><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">What\u2019s in the Boilerplate?<\/h2>\n\n\n\n<p>The template has generated many files for the plugin. Here is what\u2019s included in the plugin we just tried out from the generated template:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" width=\"192\" height=\"460\" src=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2019\/10\/GenTemp-Files.png\" alt=\"\" class=\"wp-image-24852\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2019\/10\/GenTemp-Files.png 192w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2019\/10\/GenTemp-Files-125x300.png 125w\" sizes=\"(max-width: 192px) 100vw, 192px\" \/><\/figure><\/div>\n\n\n\n<p>Many things here will be familiar to you if you\u2019ve worked on a React application before. Here are the most interesting parts:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>\/dist:<\/strong>&nbsp;The frontend files that we built with the<em>&nbsp;npm run build&nbsp;<\/em>command and that need to be deployed.<\/li><li><strong>\/src:&nbsp;<\/strong>Contains all the source code of the plugin (both the frontend in JavaScript and backend in PHP).<\/li><li><strong>package.json:<\/strong>&nbsp;Describes the various dependencies required and commands that can be run. You\u2019ll only need to edit it if you need additional JavaScript dependencies. By default, it only depends on the&nbsp;<em>cgb-script&nbsp;<\/em>library that pulls everything else.<\/li><li><strong>plugin.php:&nbsp;<\/strong>The standard file needed for a WordPress plugin.<\/li><\/ul>\n\n\n\n<p>The most interesting part is the&nbsp;<em>src\/block\/block.js<\/em>&nbsp;file that contains the JavaScript for the plugin:<\/p>\n\n\n\n<pre class=\"brush:php\">import '.\/style.scss';\nimport '.\/editor.scss';\n\nconst { __ } = wp.i18n;\nconst { registerBlockType } = wp.blocks;\n\nregisterBlockType('cgb\/block-cp-aside-gutenberg-block', {\n   title: __('cp-aside-gutenberg-block'),\n   icon: 'shield', \/\/ Icon used for the block from Dashicons\n   category: 'common',\n   edit: function(props) {\n      return (\n         &lt;div className={ props.className }&gt;Hello from the backend.&lt;\/div&gt;\n         );\n   },\n   save: function(props) {\n      return (&lt;div&gt;Hello from the frontend.&lt;\/div&gt;);\n   },\n} );\n<\/pre>\n\n\n\n<p>The Gutenberg Block API used to extend the editor makes the&nbsp;<em>registerBlockType&nbsp;<\/em>method available to add your own blocks. The&nbsp;<em>registerBlockType&nbsp;<\/em>method describes the block and what happens when displaying for the editor or from a post.<\/p>\n\n\n\n<p>It includes metadata about the block such as its&nbsp;<em>title<\/em>,&nbsp;<em>icon&nbsp;<\/em>and&nbsp;<em>category&nbsp;<\/em>in the editor. It also includes the following two functions where most of the logic of the block lives:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>edit<\/strong>: The fields that are shown in the Gutenberg editor to modify the content of the block.<\/li><li><strong>save<\/strong>: The components that describe how to render the block in the post. The rendered markup is serialized and saved with the rest of the post so React is not needed when displaying the post.<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Adding a Rich Text Field<\/h2>\n\n\n\n<p>Now that a basic block is available, let\u2019s modify it to display content as an &lt;aside&gt; HTML tag. At the same time, we\u2019ll also add an editable rich text field so we can add this content from the editor.<\/p>\n\n\n\n<p>To add the editable field, the block must now store a value in the block since it needs to render it. In the Block API, values are registered as a list of attributes in the&nbsp;<em>registerBlockType&nbsp;<\/em>method.<\/p>\n\n\n\n<p>Attributes behave similarly to the state in React, but they contain some extra information so they can be managed by the Block API. The definition of the attribute specifies how to map the rendered content saved into the block to the content.<\/p>\n\n\n\n<p>This block will have only one attribute named&nbsp;<em>content<\/em>. This attribute will look for the children inside the element described by the&nbsp;<em>.cp-aside-gutenberg-block-content&nbsp;<\/em>selector. The type of the content is an array because the block will contain many paragraphs (&lt;p&gt;) created by the rich text editor.<\/p>\n\n\n\n<pre class=\"brush:php\">attributes: {\n    content: {\n        type: 'array',\n        source: 'children',\n        selector: '.cp-aside-gutenberg-block-content'\n    }\n},\n<\/pre>\n\n\n\n<p>The following documentation includes all the data type supported by the&nbsp;<em>attributes<\/em>&nbsp;property :&nbsp;<a href=\"https:\/\/developer.wordpress.org\/block-editor\/developers\/block-api\/block-attributes\/\">https:\/\/developer.wordpress.org\/block-editor\/developers\/block-api\/block-attributes\/<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Editing the Content of the Block<\/h3>\n\n\n\n<p>When editing the post in Gutenberg, the&nbsp;<em>edit&nbsp;<\/em>method will receive the current value of the&nbsp;<em>attributes&nbsp;<\/em>as a parameter so it can show the controls needed to edit them. It also receives a&nbsp;<em>setAttributes&nbsp;<\/em>to update the current value of the attributes when the control is edited.<\/p>\n\n\n\n<pre class=\"brush:php\">edit: ({ attributes, setAttributes }) =&gt; {\n    const updateContent = (value) =&gt; {\n        setAttributes({content: value})\n        }\n\n    return (\n        &lt;RichText tagName=\"aside\" \n                  multiline=\"p\" \n                  value={attributes.content} \n                  className=\"cp-aside-gutenberg-block-content\" \n                  onChange={updateContent} \/&gt;\n    );\n}\n<\/pre>\n\n\n\n<p>Those values will be used to initialize the&nbsp;<em>RichText&nbsp;<\/em>control already available with Gutenberg (see the complete example at the bottom of the post to see how to import it in your block) .<\/p>\n\n\n\n<p>Since it\u2019s a React control, the name of the attribute for CSS class of the control is&nbsp;<em>className&nbsp;<\/em>instead of&nbsp;<em>class&nbsp;<\/em>in HTML. You can also specify which tag type is the parent of the control, so in that case we\u2019ll use &lt;aside&gt; to get the result we wish.<\/p>\n\n\n\n<p>When the content of the editor change, the method specified in the&nbsp;<em>onChange&nbsp;<\/em>attribute of the&nbsp;<em>RichText&nbsp;<\/em>control is called and the current value is updated.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Saving the Content of the Block<\/h3>\n\n\n\n<p>When the&nbsp;<em>save&nbsp;<\/em>method is called to render the control and save the result, it also receives the current value of the&nbsp;<em>attributes&nbsp;<\/em>as a parameter (but not the&nbsp;<em>setAttributes&nbsp;<\/em>method since it won\u2019t change the current value).<\/p>\n\n\n\n<pre class=\"brush:php\">save: (props) =&gt; {\n    return (\n        &lt;RichText.Content tagName=\"aside\" \n                          value={props.attributes.content} \n                          className=\"cp-aside-gutenberg-block-content\" \/&gt;\n    );\n}\n<\/pre>\n\n\n\n<p>It then uses the&nbsp;<em>RichText.Content&nbsp;<\/em>control to render the value correctly as rich text so it can be displayed later, so the parameters are similar to the&nbsp;<em>RichText&nbsp;<\/em>editor control.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">CSS for the Block<\/h3>\n\n\n\n<p>To complete the plugin, let\u2019s add this little bit of CSS in&nbsp;<em>src\\block\\style.scss<\/em>&nbsp;to show a small border around the aside block. I\u2019ve kept it simple since it will be most likely edited at the theme level.<\/p>\n\n\n\n<p>This style is applied in the editor and in the post preview; there is also a&nbsp;<em>src\\block\\editor.scss<\/em>&nbsp;file already created for styles specific to the editor.<\/p>\n\n\n\n<pre class=\"brush:php\">.cp-aside-gutenberg-block-content {\n  border:3px dashed #160c28;\n  margin: 1.5em 3em 1.5em 3em;\n  padding: 1em;\n  background-color: #e1efe6;\n}\n<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Final Version of the Block<\/h3>\n\n\n\n<p>Here is the complete plugin. Notice the import to be able to use the&nbsp;<em>RichText&nbsp;<\/em>control that I mentioned earlier.<\/p>\n\n\n\n<pre class=\"brush:php\">import '.\/style.scss';\nimport '.\/editor.scss';\n\nconst { __ } = wp.i18n; \/\/ Import __() from wp.i18n\nconst { registerBlockType } = wp.blocks;\nconst { RichText } = wp.editor;\n\nregisterBlockType('com-cindypotvin\/cp-aside-gutenberg-block', {\n    title: 'Aside Box',\n    description: 'Block showing a &lt;aside&gt; HTML element.',\n    icon: 'editor-justify',\n    category: 'formatting',\n    attributes: {\n      content: {\n          type: 'array',\n          source: 'children',\n          selector: '.cp-aside-gutenberg-block-content'}\n    },\n    edit: ({ attributes, setAttributes }) =&gt; {\n        const updateContent = (value) =&gt; {\n            setAttributes({content: value})\n            }\n        return (\n            &lt;RichText tagName=\"aside\" \n                      multiline=\"p\" \n                      value={attributes.content} \n                      className=\"cp-aside-gutenberg-block-content\" \n                      onChange={updateContent} \/&gt;\n        );\n    },\n    save: (props) =&gt; {\n        return (\n            &lt;RichText.Content tagName=\"aside\" \n                              value={props.attributes.content} \n                              className=\"cp-aside-gutenberg-block-content\" \/&gt;\n        );\n    }\n});\n<\/pre>\n\n\n\n<p>\n\nHere is a GitHub repository with the full code of the plugin and more comments:&nbsp;<a href=\"https:\/\/github.com\/CindyPotvin\/cp-aside-gutenberg-block\">https:\/\/github.com\/CindyPotvin\/cp-aside-gutenberg-block<\/a>.\n\n<\/p>\n\n\n\n<div class=\"attribution\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>Published on Web Code Geeks with permission by Cindy Potvin, partner at our <a href=\"\/\/www.webcodegeeks.com\/join-us\/wcg\/\" target=\"_blank\" rel=\"noopener noreferrer\">WCG program<\/a>. See the original article here: <a href=\"https:\/\/blog.cindypotvin.com\/create-a-minimal-custom-gutenberg-block-in-wordpress\/\" target=\"_blank\" rel=\"noopener noreferrer\">Create a Minimal Custom Gutenberg Block in WordPress<\/a><\/p>\n<p>Opinions expressed by Web Code Geeks contributors are their own.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>I\u2019ve started playing with the new Gutenberg editor in WordPress, and the experience is a lot more modern than the old TinyMCE editor that\u2019s been around for a good 15 years (and I\u2019ve had blogs for almost that long!). Instead of editing all the content of the post at once, the Gutenberg editor works with &hellip;<\/p>\n","protected":false},"author":36,"featured_media":932,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[],"class_list":["post-24846","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wordpress"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Create a Minimal Custom Gutenberg Block in WordPress - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"Interested to learn about Gutenberg Block? Check our article explaining how to Create a Minimal Custom Gutenberg Block in WordPress\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webcodegeeks.com\/wordpress\/create-a-minimal-custom-gutenberg-block-in-wordpress\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Create a Minimal Custom Gutenberg Block in WordPress - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"Interested to learn about Gutenberg Block? Check our article explaining how to Create a Minimal Custom Gutenberg Block in WordPress\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/wordpress\/create-a-minimal-custom-gutenberg-block-in-wordpress\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2019-10-30T10:15:19+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/wordpress-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Cindy Potvin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/CindyPtn\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Cindy Potvin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/wordpress\/create-a-minimal-custom-gutenberg-block-in-wordpress\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/wordpress\/create-a-minimal-custom-gutenberg-block-in-wordpress\/\"},\"author\":{\"name\":\"Cindy Potvin\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/5c5df30ebfba793235473ab81edbd742\"},\"headline\":\"Create a Minimal Custom Gutenberg Block in WordPress\",\"datePublished\":\"2019-10-30T10:15:19+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/wordpress\/create-a-minimal-custom-gutenberg-block-in-wordpress\/\"},\"wordCount\":1674,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/wordpress\/create-a-minimal-custom-gutenberg-block-in-wordpress\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/wordpress-logo.jpg\",\"articleSection\":[\"WordPress\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/wordpress\/create-a-minimal-custom-gutenberg-block-in-wordpress\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/wordpress\/create-a-minimal-custom-gutenberg-block-in-wordpress\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wordpress\/create-a-minimal-custom-gutenberg-block-in-wordpress\/\",\"name\":\"Create a Minimal Custom Gutenberg Block in WordPress - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/wordpress\/create-a-minimal-custom-gutenberg-block-in-wordpress\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/wordpress\/create-a-minimal-custom-gutenberg-block-in-wordpress\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/wordpress-logo.jpg\",\"datePublished\":\"2019-10-30T10:15:19+00:00\",\"description\":\"Interested to learn about Gutenberg Block? Check our article explaining how to Create a Minimal Custom Gutenberg Block in WordPress\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/wordpress\/create-a-minimal-custom-gutenberg-block-in-wordpress\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/wordpress\/create-a-minimal-custom-gutenberg-block-in-wordpress\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/wordpress\/create-a-minimal-custom-gutenberg-block-in-wordpress\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/wordpress-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/wordpress-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/wordpress\/create-a-minimal-custom-gutenberg-block-in-wordpress\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"WordPress\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/wordpress\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Create a Minimal Custom Gutenberg Block in WordPress\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/5c5df30ebfba793235473ab81edbd742\",\"name\":\"Cindy Potvin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/957776d6732b26df4f63c29c8a3cb127ef09eb38b9f5befec1840ee3a1abed32?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/957776d6732b26df4f63c29c8a3cb127ef09eb38b9f5befec1840ee3a1abed32?s=96&d=mm&r=g\",\"caption\":\"Cindy Potvin\"},\"description\":\"Cindy is a programmer with over 5 years of experience developing web applications. She also works on Android applications and share her knowledge via her blog and on Twitter.\",\"sameAs\":[\"http:\/\/blog.cindypotvin.com\/\",\"https:\/\/x.com\/https:\/\/twitter.com\/CindyPtn\"],\"url\":\"https:\/\/www.webcodegeeks.com\/author\/cindy-potvin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Create a Minimal Custom Gutenberg Block in WordPress - Web Code Geeks - 2026","description":"Interested to learn about Gutenberg Block? Check our article explaining how to Create a Minimal Custom Gutenberg Block in WordPress","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webcodegeeks.com\/wordpress\/create-a-minimal-custom-gutenberg-block-in-wordpress\/","og_locale":"en_US","og_type":"article","og_title":"Create a Minimal Custom Gutenberg Block in WordPress - Web Code Geeks - 2026","og_description":"Interested to learn about Gutenberg Block? Check our article explaining how to Create a Minimal Custom Gutenberg Block in WordPress","og_url":"https:\/\/www.webcodegeeks.com\/wordpress\/create-a-minimal-custom-gutenberg-block-in-wordpress\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_published_time":"2019-10-30T10:15:19+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/wordpress-logo.jpg","type":"image\/jpeg"}],"author":"Cindy Potvin","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/CindyPtn","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Cindy Potvin","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/wordpress\/create-a-minimal-custom-gutenberg-block-in-wordpress\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/wordpress\/create-a-minimal-custom-gutenberg-block-in-wordpress\/"},"author":{"name":"Cindy Potvin","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/5c5df30ebfba793235473ab81edbd742"},"headline":"Create a Minimal Custom Gutenberg Block in WordPress","datePublished":"2019-10-30T10:15:19+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/wordpress\/create-a-minimal-custom-gutenberg-block-in-wordpress\/"},"wordCount":1674,"commentCount":1,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/wordpress\/create-a-minimal-custom-gutenberg-block-in-wordpress\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/wordpress-logo.jpg","articleSection":["WordPress"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/wordpress\/create-a-minimal-custom-gutenberg-block-in-wordpress\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/wordpress\/create-a-minimal-custom-gutenberg-block-in-wordpress\/","url":"https:\/\/www.webcodegeeks.com\/wordpress\/create-a-minimal-custom-gutenberg-block-in-wordpress\/","name":"Create a Minimal Custom Gutenberg Block in WordPress - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/wordpress\/create-a-minimal-custom-gutenberg-block-in-wordpress\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/wordpress\/create-a-minimal-custom-gutenberg-block-in-wordpress\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/wordpress-logo.jpg","datePublished":"2019-10-30T10:15:19+00:00","description":"Interested to learn about Gutenberg Block? Check our article explaining how to Create a Minimal Custom Gutenberg Block in WordPress","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/wordpress\/create-a-minimal-custom-gutenberg-block-in-wordpress\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/wordpress\/create-a-minimal-custom-gutenberg-block-in-wordpress\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/wordpress\/create-a-minimal-custom-gutenberg-block-in-wordpress\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/wordpress-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/wordpress-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/wordpress\/create-a-minimal-custom-gutenberg-block-in-wordpress\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"WordPress","item":"https:\/\/www.webcodegeeks.com\/category\/wordpress\/"},{"@type":"ListItem","position":3,"name":"Create a Minimal Custom Gutenberg Block in WordPress"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/5c5df30ebfba793235473ab81edbd742","name":"Cindy Potvin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/957776d6732b26df4f63c29c8a3cb127ef09eb38b9f5befec1840ee3a1abed32?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/957776d6732b26df4f63c29c8a3cb127ef09eb38b9f5befec1840ee3a1abed32?s=96&d=mm&r=g","caption":"Cindy Potvin"},"description":"Cindy is a programmer with over 5 years of experience developing web applications. She also works on Android applications and share her knowledge via her blog and on Twitter.","sameAs":["http:\/\/blog.cindypotvin.com\/","https:\/\/x.com\/https:\/\/twitter.com\/CindyPtn"],"url":"https:\/\/www.webcodegeeks.com\/author\/cindy-potvin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/24846","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/36"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=24846"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/24846\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/932"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=24846"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=24846"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=24846"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}