Using Custom Blocks
Why use a Custom Block?
When creating new content, or editing exiting content on your website in Drupal, one of the first questions to yourself is, how will this information be displayed? Will this information be repeated throughout the website, or will this text copy, or image, be used only once, on a single page?
The reason for the question is that if you think the same information needs to be presented in multiple places within your website, there is a time-saving trick that isn’t often well known or utilized. In this case, building a single block in the custom block library is better choice than creating multiple blocks with the same information on individual pages.
What is a Custom Block?
A custom block gives an editor the option to create one node of information and place it on multiple pages. Footer blocks at the bottom of a website are usually built this way so that they display on all the pages of a website. Other use cases may be to create a block with a "call to action", for example to direct students on how to declare a major or or contact an advisor.
Creating the Custom Block
- In the Manage administrative menu, navigate to
Structure > Block Layout > Custom Block Library.
- Click Add Custom Block. The add custom block page appears
- Choose the block you would like to add. (For example, a Beyond Basics Block)
- Fill out the fields as you would for any Beyond Basics Block, adding a title, choosing the heading level, the body and any additional styles as desired.
- Save the block.
Placing the Custom Block
- Navigate to the page that you’d like to place the Custom Block
- Click Layout and navigate to the specific area you’d like the custom block to be placed. (If necessary, add a section, then click Add Block.)
- When the Choose a Block interface appears, in the blank field, where it says (Filter by block name) type in title of the custom block you just created.
- You can choose to display the title, or not by unchecking the “display title” box.
- Add the block.
Last thoughts about Custom Blocks
- The custom block can be placed on multiple pages without recreating the block on every page.
- Edit your custom block within the custom block library, not on the page where the block is displayed. /admin/structure/block/block-content
- When you edit the content using the Custom Block Library, the content will be updated in every instance where you placed the custom block.