{"id":620,"date":"2025-03-06T15:30:00","date_gmt":"2025-03-06T20:30:00","guid":{"rendered":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/?page_id=620"},"modified":"2025-03-06T15:52:51","modified_gmt":"2025-03-06T20:52:51","slug":"creating-a-block-using-a-template","status":"publish","type":"page","link":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/creating-a-block-using-a-template\/","title":{"rendered":"Creating a Block Using a Template"},"content":{"rendered":"\n<p>Within the plugin and theme starter repos, there are two npm scripts that will aid you in creating a new block:<\/p>\n\n\n\n<ul><li><code>new-id-block<\/code>: Pulls in the skeleton of a new block based on the BU block template.<\/li><li><code>new-wp-block<\/code>: Pulls in the skeleton of the WordPress default block.<\/li><\/ul>\n\n\n\n<h2><code>new-id-block<\/code><\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"2546\" height=\"1124\" src=\"\/gutenberg\/files\/2025\/03\/SCR-20250306-npxd.png\" alt=\"Screenshot of the questions asked to build a new block from 'npm run new-id-block'\" class=\"wp-image-622\" srcset=\"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/files\/2025\/03\/SCR-20250306-npxd.png 2546w, https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/files\/2025\/03\/SCR-20250306-npxd-636x281.png 636w, https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/files\/2025\/03\/SCR-20250306-npxd-1024x452.png 1024w, https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/files\/2025\/03\/SCR-20250306-npxd-768x339.png 768w, https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/files\/2025\/03\/SCR-20250306-npxd-1536x678.png 1536w, https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/files\/2025\/03\/SCR-20250306-npxd-2048x904.png 2048w\" sizes=\"(max-width: 2546px) 100vw, 2546px\" \/><\/figure>\n\n\n\n<p>Running <code>npm run new-id-block<\/code> will download the BU block template from NPM, and ask a series of questions to name the new block and set up the directory structure. The &#8220;theme&#8221; and &#8220;plugin&#8221; variants are both dynamic blocks. There is a third option, &#8220;static&#8221;, which will give the skeleton of a static block, but still BU-specific.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" src=\"\/gutenberg\/files\/2025\/03\/SCR-20250306-nrlr.png\" alt=\"Screenshot of the BU plugin block directory tree.\" class=\"wp-image-626\" width=\"296\" height=\"306\"\/><\/figure>\n\n\n\n<h2><code>new-wp-block<\/code><\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"2544\" height=\"874\" src=\"\/gutenberg\/files\/2025\/03\/SCR-20250306-nudo.png\" alt=\"Screenshot of the WordPress default block creation script.\" class=\"wp-image-627\" srcset=\"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/files\/2025\/03\/SCR-20250306-nudo.png 2544w, https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/files\/2025\/03\/SCR-20250306-nudo-636x219.png 636w, https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/files\/2025\/03\/SCR-20250306-nudo-1024x352.png 1024w, https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/files\/2025\/03\/SCR-20250306-nudo-768x264.png 768w, https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/files\/2025\/03\/SCR-20250306-nudo-1536x528.png 1536w, https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/files\/2025\/03\/SCR-20250306-nudo-2048x704.png 2048w\" sizes=\"(max-width: 2544px) 100vw, 2544px\" \/><\/figure>\n\n\n\n<p>The <code>new-wp-block<\/code> will run through a similar set of questions, but the difference is there are only two options for variants, &#8220;static&#8221; and &#8220;dynamic&#8221;, defaulting on &#8220;static&#8221;. As you can see below, the tree is much simpler.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" src=\"\/gutenberg\/files\/2025\/03\/SCR-20250306-nuhj.png\" alt=\"Screenshot of the WordPress standard block skeleton, in the static variant.\" class=\"wp-image-628\" width=\"272\" height=\"180\" srcset=\"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/files\/2025\/03\/SCR-20250306-nuhj.png 498w, https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/files\/2025\/03\/SCR-20250306-nuhj-496x330.png 496w\" sizes=\"(max-width: 272px) 100vw, 272px\" \/><\/figure>\n\n\n\n<p>From here, you can customize the skeletons for the plugin or theme&#8217;s requirements. The blocks will compile into the build folder and will be available in the edit screen.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Within the plugin and theme starter repos, there are two npm scripts that will aid you in creating a new block: new-id-block: Pulls in the skeleton of a new block based on the BU block template.new-wp-block: Pulls in the skeleton of the WordPress default block. new-id-block Running npm run new-id-block will download the BU block [&hellip;]<\/p>\n","protected":false},"author":6752,"featured_media":0,"parent":0,"menu_order":1,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"status-is-a-reserved-term":[],"assignee":[],"_links":{"self":[{"href":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/wp-json\/wp\/v2\/pages\/620"}],"collection":[{"href":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/wp-json\/wp\/v2\/users\/6752"}],"replies":[{"embeddable":true,"href":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/wp-json\/wp\/v2\/comments?post=620"}],"version-history":[{"count":5,"href":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/wp-json\/wp\/v2\/pages\/620\/revisions"}],"predecessor-version":[{"id":633,"href":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/wp-json\/wp\/v2\/pages\/620\/revisions\/633"}],"wp:attachment":[{"href":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/wp-json\/wp\/v2\/media?parent=620"}],"wp:term":[{"taxonomy":"status-is-a-reserved-term","embeddable":true,"href":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/wp-json\/wp\/v2\/status-is-a-reserved-term?post=620"},{"taxonomy":"assignee","embeddable":true,"href":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/wp-json\/wp\/v2\/assignee?post=620"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}