{"id":590,"date":"2025-02-21T10:53:10","date_gmt":"2025-02-21T15:53:10","guid":{"rendered":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/?page_id=590"},"modified":"2025-10-24T13:10:55","modified_gmt":"2025-10-24T17:10:55","slug":"basic-dynamic-block","status":"publish","type":"page","link":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/getting-started\/basic-dynamic-block\/","title":{"rendered":"Building a Basic Dynamic Block"},"content":{"rendered":"\n<p>Let&#8217;s go step by step to create a simple Dynamic Block. You might not need every technique used in this example, but it covers a lot of common features you may need in developing your own blocks.<\/p>\n\n\n\n<h2>Setup\/Assumptions<\/h2>\n\n\n\n<ol><li>You are working in a theme repo cloned from <a href=\"https:\/\/github.com\/bu-ist\/responsive-child-starter-3x-block-editor\">responsive-child-starter-3x-block-editor<\/a> and are using npm 20. I am using <a href=\"https:\/\/github.com\/bu-ist\/labs-theme-blocks\">labs-theme-blocks<\/a>.<\/li><li>You are familiar with the command line and are running <code>npm start<\/code>&nbsp;to rebuild files on save.<\/li><li>You&#8217;ve read and understand <a href=\"https:\/\/developer.bu.edu\/gutenberg\/getting-started\/building-a-block\/block-architecture\/\">Block Architecture<\/a> and <a href=\"https:\/\/developer.bu.edu\/gutenberg\/getting-started\/building-a-block\/dynamic-vs-static\/\">Dynamic vs Static<\/a>.<\/li><li>Screenshots will depict VS Code.<\/li><li>This is what the final code will look like: <a href=\"https:\/\/github.com\/bu-ist\/labs-theme-blocks\/tree\/sandbox\/src\/blocks\/theme\">https:\/\/github.com\/bu-ist\/labs-theme-blocks\/tree\/sandbox\/src\/blocks\/theme<\/a><\/li><\/ol>\n\n\n\n<h2>Final Product<\/h2>\n\n\n\n<p>This is what we will build by the end of this tutorial:<\/p>\n\n\n\n<p class=\"has-text-align-center\">\u25bc\u25bc\u25bc<\/p>\n\n\n<p><!-- wp:r3-id-documentation\/tutorial-01--><br \/>hello world<br \/><!-- \/wp:r3-id-documentation\/tutorial-01 --><\/p>\n<p><!-- wp:paragraph {\"align\":\"center\"} --><\/p>\n<p class=\"has-text-align-center\">\u25b2\u25b2\u25b2<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:heading --><\/p>\n<h2>Step 1: Create a New Block Using Create-Block Template<\/h2>\n<p><!-- \/wp:heading --><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p>In the command terminal, from the root of your project run <code>npm run new-id-block<\/code>.<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p>This will start a series of prompts. Here&#8217;s what was used to make this block:<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:list --><\/p>\n<ul>\n<li>The template variant to use for this block: <strong>tutorial-1<\/strong><\/li>\n<li>The block slug used for identification (also the output folder name): <strong>tutorial-1<\/strong><\/li>\n<li>The internal namespace for the block name (something unique for your products): <strong>labs-theme-blocks<\/strong><\/li>\n<li>The display title for your block: <strong>Tutorial 1 Block<\/strong><\/li>\n<li>The short description for your block (optional): <strong>My first block!<\/strong><\/li>\n<li>The dashicon to make it easier to identify your block (optional): <strong>block-default<\/strong><\/li>\n<li>The category name to help users browse and discover your block: <strong>widgets<\/strong><\/li>\n<li>The text domain used to make strings translatable in the block (optional): <strong>labs-theme-blocks<\/strong><\/li>\n<\/ul>\n<p><!-- \/wp:list --><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p>When this is done there will be a new block in the folder <code>\/src\/blocks\/theme<\/code>.<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p>Check out <strong><a href=\"https:\/\/developer.bu.edu\/gutenberg\/getting-started\/using-create-block-template\/\">Using Create-Block Template<\/a><\/strong> page to learn more about what is happening in this step here and an overview of all the files in this directory. Otherwise, get ready to get your feet wet!<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:paragraph {\"backgroundColor\":\"primary\"} --><\/p>\n<p class=\"has-primary-background-color has-background\">@todo After adding the block we should give instructions how to start compiling the block and check first that it appears in the admin before starting to modify it. That way they see it working before adding attributes.<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:heading --><\/p>\n<h2>Step 2: Updating the Files<\/h2>\n<p><!-- \/wp:heading --><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p>Now it&#8217;s time to start work on the block itself. In your IDE, navigate to <code>\/src\/blocks\/theme<\/code>\u00a0to begin.<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:heading {\"level\":3} --><\/p>\n<h3>Core Block Files<\/h3>\n<p><!-- \/wp:heading --><\/p>\n<p><!-- wp:heading {\"level\":4} --><\/p>\n<h4><code>block.json <\/code><\/h4>\n<p><!-- \/wp:heading --><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p>Simplifies the process of defining and registering a block by using the same block\u2019s definition in JSON format to register the block on both the server and the client.<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p>We defined everything we need for this tutorial through the command line create-block command, but it&#8217;s worth looking at.<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:r3-id-documentation\/code-prism {\"code\":\"https:\/\/github.com\/bu-ist\/labs-theme-blocks\/blob\/sandbox\/src\/blocks\/theme\/block.json\",\"language\":\"json\"} \/--><\/p>\n<p><!-- wp:paragraph {\"backgroundColor\":\"primary\"} --><\/p>\n<p class=\"has-primary-background-color has-background\">In this tutorial, we will be adding 2 fields to the block, so we will be want to add 2 attributes here. The key should be named something that clearly references what the field will store, and the type should define what kind of value is being stored. See lines 36-43.<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:paragraph {\"backgroundColor\":\"primary\"} --><\/p>\n<p class=\"has-primary-background-color has-background\">For the attributes step, suggest adding a link to:\u00a0<a target=\"_blank\" href=\"https:\/\/developer.bu.edu\/gutenberg\/handbook\/wp-core\/block-architecture\/attributes\/\" rel=\"noreferrer noopener\">https:\/\/developer.bu.edu\/gutenberg\/handbook\/wp-core\/block-architecture\/attributes\/<\/a><a href=\"https:\/\/buweb.slack.com\/archives\/C04396UG9DK\/p1743689214453259?thread_ts=1741979741.140949&amp;cid=C04396UG9DK\">10:06<\/a>&#8220;All this is doing is taking the new value and saving it to the block attribute.&#8221;Let&#8217;s change this to:<br \/>&#8220;All this is doing is taking the new value and storing it to the block attribute. When the post is saved, the stored attribute will be saved to the post&#8217;s content in the database.&#8221;<a href=\"https:\/\/buweb.slack.com\/archives\/C04396UG9DK\/p1743689343647859?thread_ts=1741979741.140949&amp;cid=C04396UG9DK\">10:09<\/a>After the reader adds the attributes, we should have a step before render.php that says something like:Compile, and check the editor. If you insert your new block you should see a Title field and Excerpt field with the placeholder values you set in the RichText Component.Set a value for each and save the post. Then reload and verify your saved values are shown in the block.<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:list --><\/p>\n<ul>\n<li>See <a href=\"https:\/\/developer.bu.edu\/gutenberg\/getting-started\/building-a-block\/block-js\/\">block.json<\/a> for more information.<\/li>\n<\/ul>\n<p><!-- \/wp:list --><\/p>\n<p><!-- wp:separator --><\/p>\n<hr class=\"wp-block-separator\" \/><!-- \/wp:separator -->\n<p><\/p>\n<p><!-- wp:heading {\"level\":4} --><\/p>\n<h4><code>index.js<\/code><\/h4>\n<p><!-- \/wp:heading --><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p>The entry point file for JavaScript that should only get loaded in the Block Editor. It\u2019s responsible for calling the registerBlockType function to register the block on the client and typically imports the edit.js and save.js files to get the functions required for block registration.<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:r3-id-documentation\/code-prism {\"code\":\"https:\/\/github.com\/bu-ist\/labs-theme-blocks\/blob\/sandbox\/src\/blocks\/theme\/index.js\",\"language\":\"js\",\"lines\":\"36-43\"} \/--><\/p>\n<p><!-- wp:separator --><\/p>\n<hr class=\"wp-block-separator\" \/><!-- \/wp:separator -->\n<p><\/p>\n<p><!-- wp:heading {\"level\":4} --><\/p>\n<h4><code>edit.js<\/code><\/h4>\n<p><!-- \/wp:heading --><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p>Contains the React component responsible for rendering the block\u2019s editing user interface, allowing users to interact with and customize the block\u2019s content and settings in the Block Editor. This component gets passed to the edit property of the registerBlockType function in the <code>index.js<\/code> file.<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:r3-id-documentation\/code-prism {\"code\":\"https:\/\/github.com\/bu-ist\/labs-theme-blocks\/blob\/sandbox\/src\/blocks\/theme\/edit.js\",\"language\":\"js\",\"lines\":\"14,36-44,49-68\"} \/--><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p>This will be the biggest edit of the day. The attributes we just defined in index.js? Time to set them up in the editor.<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p>First, we need to import the RichText component from WordPress.See line 14.<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p>Now lets define the attributes we will be using. Go to line 36 and destructure each from the attributes object.<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p>Now let&#8217;s add these to the Editor. Jump down to line 49. First we will add a <a href=\"https:\/\/developer.wordpress.org\/block-editor\/reference-guides\/richtext\/\">RichText component<\/a> for the Title, defining the various properties and constraints we want it to have. <code>value<\/code>\u00a0will be the attribute we defined, and <code>onChange<\/code>\u00a0will be how we update this value. in the next step.<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p>Jump up to line 38. We are going to write a simple function that is called when the RichText component we just made is changed. All this is doing is taking the new value and saving it to the block attribute.<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p>Excellent, do the same for the <code>excerpt<\/code>\u00a0and we are done here. See lines 57-68 and 42-44.<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:paragraph {\"backgroundColor\":\"primary\"} --><\/p>\n<p class=\"has-primary-background-color has-background\">make a note about &lt;&gt; fragment<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:separator --><\/p>\n<hr class=\"wp-block-separator\" \/><!-- \/wp:separator -->\n<p><\/p>\n<p><!-- wp:heading {\"level\":3} --><\/p>\n<h3>PHP<\/h3>\n<p><!-- \/wp:heading --><\/p>\n<p><!-- wp:heading {\"level\":4} --><\/p>\n<h4><code>render.php<\/code><\/h4>\n<p><!-- \/wp:heading --><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p>PHP file to use when rendering the block type on the server to show on the front end.<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:r3-id-documentation\/code-prism {\"code\":\"https:\/\/github.com\/bu-ist\/labs-theme-blocks\/blob\/sandbox\/src\/blocks\/theme\/render.php\",\"language\":\"php\",\"lines\":\"18-24\"} \/--><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p>Let&#8217;s setup how this block is going to appear in the front end. You can use any <code>php<\/code>\u00a0and WordPress methods you want here. In this example, we simply check to see if an attribute is defined, and if it is, render it to the page. See lines 18-24.<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:r3-id-documentation\/code-prism {\"code\":\"https:\/\/github.com\/bu-ist\/labs-theme-blocks\/blob\/sandbox\/src\/blocks\/theme\/block.json\",\"language\":\"json\",\"lines\":\"14\"} \/--><\/p>\n<p><!-- wp:list --><\/p>\n<ul>\n<li>See <a href=\"https:\/\/developer.bu.edu\/gutenberg\/getting-started\/building-a-block\/render-template\/\">Render Template<\/a> for more information.<\/li>\n<\/ul>\n<p><!-- \/wp:list --><\/p>\n<p><!-- wp:separator --><\/p>\n<hr class=\"wp-block-separator\" \/><!-- \/wp:separator -->\n<p><\/p>\n<p><!-- wp:heading {\"level\":3} --><\/p>\n<h3>Styles<\/h3>\n<p><!-- \/wp:heading --><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p><em>These files are all optional and will not be used in this tutorial. Feel free to play around with them though! You can put whatever you want here. I&#8217;ve added a few just to visually confirm that the file is loading as intended.<\/em><\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p>The theme starter has the option to bundle all block styles into a single css file. Out of the box, your new block style is not included in the bundle. You will need to import it in <code>blocks-bundled.scss<\/code> (located in the parent directory).<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:list --><\/p>\n<ul>\n<li>In\u00a0<code><a href=\"https:\/\/github.com\/bu-ist\/labs-theme-blocks\/blob\/sandbox\/src\/blocks\/blocks-bundled.scss\">blocks-bundled.scss<\/a><\/code>\u00a0add a new line:<\/li>\n<\/ul>\n<p><!-- \/wp:list --><\/p>\n<p><!-- wp:r3-id-documentation\/code-prism {\"code\":\"https:\/\/github.com\/bu-ist\/labs-theme-blocks\/blob\/sandbox\/src\/blocks\/blocks-bundled.scss\",\"language\":\"scss\",\"lines\":\"20\"} \/--><\/p>\n<p><!-- wp:separator --><\/p>\n<hr class=\"wp-block-separator\" \/><!-- \/wp:separator -->\n<p><\/p>\n<p><!-- wp:heading {\"level\":4} --><\/p>\n<h4><code>block-base.scss<\/code><\/h4>\n<p><!-- \/wp:heading --><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p>SCSS partial that contains all of the base (structural) styles for this block. These are compiled both individually and in a bundle.<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:r3-id-documentation\/code-prism {\"code\":\"https:\/\/github.com\/bu-ist\/labs-theme-blocks\/blob\/sandbox\/src\/blocks\/theme\/block-base.scss\",\"language\":\"css\"} \/--><\/p>\n<p><!-- wp:separator --><\/p>\n<hr class=\"wp-block-separator\" \/><!-- \/wp:separator -->\n<p><\/p>\n<p><!-- wp:heading {\"level\":4} --><\/p>\n<h4><code>block-decorative.scss<\/code><\/h4>\n<p><!-- \/wp:heading --><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p>SCSS partial that contains all of the decorative (opinionated) styles for this block. These are compiled in a bundle.<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p><strong>Note: this file is only generated if you select the <em>plugin<\/em> template variant.<\/strong><\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:r3-id-documentation\/code-prism {\"code\":\"https:\/\/github.com\/bu-ist\/labs-plugin-blocks\/blob\/timk\/simple-block-examples\/src\/blocks\/plugin\/block-decorative.scss\",\"language\":\"css\"} \/--><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p>Out of the box, this file will not get enqueued. You will need to import it in <code>blocks-decorative.scss<\/code> (located in the parent directory).<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:list --><\/p>\n<ul>\n<li>In <code><a href=\"https:\/\/github.com\/bu-ist\/labs-plugin-blocks\/blob\/sandbox\/src\/blocks\/blocks-decorative.scss\">blocks-decorative.scss<\/a><\/code>\u00a0add a new line:<\/li>\n<\/ul>\n<p><!-- \/wp:list --><\/p>\n<p><!-- wp:r3-id-documentation\/code-prism {\"code\":\"https:\/\/github.com\/bu-ist\/labs-plugin-blocks\/blob\/timk\/simple-block-examples\/src\/blocks\/blocks-decorative.scss\",\"language\":\"scss\",\"lines\":\"6\"} \/--><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p>This ensures the styles for your new block will be bundled with the other block styles when the theme serves the bundled style file.<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:separator --><\/p>\n<hr class=\"wp-block-separator\" \/><!-- \/wp:separator -->\n<p><\/p>\n<p><!-- wp:heading {\"level\":4} --><\/p>\n<h4><code>editor.scss<\/code><\/h4>\n<p><!-- \/wp:heading --><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p>Styles that are applied inside the editor only.<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:r3-id-documentation\/code-prism {\"code\":\"https:\/\/github.com\/bu-ist\/labs-theme-blocks\/blob\/sandbox\/src\/blocks\/theme\/editor.scss\",\"language\":\"scss\"} \/--><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p>If you are not using this, remove the <code>editorStyle<\/code> entry from <code>block.json<\/code>.<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:r3-id-documentation\/code-prism {\"code\":\"https:\/\/github.com\/bu-ist\/labs-theme-blocks\/blob\/sandbox\/src\/blocks\/theme\/block.json\",\"language\":\"json\",\"lines\":\"12\"} \/--><\/p>\n<p><!-- wp:list --><\/p>\n<ul>\n<li>See <a href=\"https:\/\/developer.bu.edu\/gutenberg\/getting-started\/building-a-block\/editor-styling\/\">Editor Styling<\/a> for more information.<\/li>\n<\/ul>\n<p><!-- \/wp:list --><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p><em>Note, this file is generated from within <code>edit.js<\/code><\/em>.<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:r3-id-documentation\/code-prism {\"code\":\"https:\/\/github.com\/bu-ist\/labs-theme-blocks\/blob\/sandbox\/src\/blocks\/theme\/edit.js\",\"language\":\"js\",\"lines\":\"22\"} \/--><\/p>\n<p><!-- wp:separator --><\/p>\n<hr class=\"wp-block-separator\" \/><!-- \/wp:separator -->\n<p><\/p>\n<p><!-- wp:heading {\"level\":4} --><\/p>\n<h4><code>style.scss<\/code><\/h4>\n<p><!-- \/wp:heading --><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p>Styles that are applied both on the front of your site and in the editor. Our block template @imports some common tools and the <code>block-base.scss<\/code> in order to stay DRY.<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:r3-id-documentation\/code-prism {\"code\":\"https:\/\/github.com\/bu-ist\/labs-theme-blocks\/blob\/sandbox\/src\/blocks\/theme\/style.scss\",\"language\":\"scss\"} \/--><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p>If you are not using this, remove the <code>style<\/code> entry from <code>block.json<\/code>.<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:r3-id-documentation\/code-prism {\"code\":\"https:\/\/github.com\/bu-ist\/labs-theme-blocks\/blob\/sandbox\/src\/blocks\/theme\/block.json\",\"language\":\"json\",\"lines\":\"13\"} \/--><\/p>\n<p><!-- wp:list --><\/p>\n<ul>\n<li>See <a href=\"https:\/\/developer.bu.edu\/gutenberg\/getting-started\/building-a-block\/frontend-styling\/\">Frontend Styling<\/a><\/li>\n<\/ul>\n<p><!-- \/wp:list --><\/p>\n<p><!-- wp:separator --><\/p>\n<hr class=\"wp-block-separator\" \/><!-- \/wp:separator -->\n<p><\/p>\n<p><!-- wp:heading {\"level\":3} --><\/p>\n<h3>Scripts<\/h3>\n<p><!-- \/wp:heading --><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p><em>This file is optional and will not be used in this tutorial. Feel free to play around with it though! You can put whatever you want here. In the example, I added a console.log statement just to ensure the script was loading.<\/em><\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:heading {\"level\":3} --><\/p>\n<h3><code>script.js<\/code><\/h3>\n<p><!-- \/wp:heading --><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p>Use this file for JavaScript code that you want to run in the front-end on posts\/pages that contain this block.<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:r3-id-documentation\/code-prism {\"code\":\"https:\/\/github.com\/bu-ist\/labs-theme-blocks\/blob\/sandbox\/src\/blocks\/theme\/view.js\",\"language\":\"js\",\"lines\":\"\"} \/--><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p>If you are not using this, remove the <code>script<\/code> entry from <code>block.json<\/code>.<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:r3-id-documentation\/code-prism {\"code\":\"https:\/\/github.com\/bu-ist\/labs-theme-blocks\/blob\/sandbox\/src\/blocks\/theme\/block.json\",\"language\":\"json\",\"lines\":\"15\"} \/--><\/p>\n<p><!-- wp:list --><\/p>\n<ul>\n<li>See <a href=\"https:\/\/developer.bu.edu\/gutenberg\/getting-started\/building-a-block\/frontend-js\/\">Frontend JS<\/a> for more information.<\/li>\n<\/ul>\n<p><!-- \/wp:list --><\/p>\n<p><!-- wp:separator --><\/p>\n<hr class=\"wp-block-separator\" \/><!-- \/wp:separator -->\n<p><\/p>\n<p><!-- wp:heading --><\/p>\n<h2>Bringing it all Together<\/h2>\n<p><!-- \/wp:heading --><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p>Wow, we should have the workings of a basic block now! One last thing to do &#8211; build it:<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:list --><\/p>\n<ul>\n<li>Make sure you are in the root of your repo.<\/li>\n<li>In the command line, run <code>npm run build<\/code>\u00a0(you could also run <code>npm start<\/code>\u00a0to watch changes as you work)<\/li>\n<li>Make sure everything is pushed up to the server.<\/li>\n<li>Go to a page and see if you block is there!<\/li>\n<\/ul>\n<p><!-- \/wp:list --><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p>Uh oh, not working? Reach out to Tim King, he wrote this&#8230;<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:heading --><\/p>\n<h2>Next Steps<\/h2>\n<p><!-- \/wp:heading --><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p>There are many <a href=\"https:\/\/github.com\/bu-ist\/r3-id-documentation\/tree\/develop\/src\/blocks\">examples in the r3-id-documentation repo<\/a> that will show you how to add InspectorControls, split code into modules, and more!<\/p>\n<p><!-- \/wp:paragraph --><\/p>","protected":false},"excerpt":{"rendered":"<p>Let&#8217;s go step by step to create a simple Dynamic Block. You might not need every technique used in this example, but it covers a lot of common features you may need in developing your own blocks. Setup\/Assumptions You are working in a theme repo cloned from responsive-child-starter-3x-block-editor and are using npm 20. I am [&hellip;]<\/p>\n","protected":false},"author":9175,"featured_media":0,"parent":16,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"status-is-a-reserved-term":[5],"assignee":[4],"_links":{"self":[{"href":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/wp-json\/wp\/v2\/pages\/590"}],"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\/9175"}],"replies":[{"embeddable":true,"href":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/wp-json\/wp\/v2\/comments?post=590"}],"version-history":[{"count":9,"href":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/wp-json\/wp\/v2\/pages\/590\/revisions"}],"predecessor-version":[{"id":747,"href":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/wp-json\/wp\/v2\/pages\/590\/revisions\/747"}],"up":[{"embeddable":true,"href":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/wp-json\/wp\/v2\/pages\/16"}],"wp:attachment":[{"href":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/wp-json\/wp\/v2\/media?parent=590"}],"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=590"},{"taxonomy":"assignee","embeddable":true,"href":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/wp-json\/wp\/v2\/assignee?post=590"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}