What Are Shared Layouts?
From our delightful documentation on shared layouts:
“A shared layout is a layout outside the layout hierarchy that you can assign to any individual layouts. Unlike with cloning, once you assign a shared layout to a layout, that layout can’t be customized directly. Use a shared layout when you want to lock particular layouts down and not allow customizations to any one of them separately.
“Changes to a layout template apply to all layouts using that layout template. Further, due to layout inheritance, any uncustomized children of a layout that has a layout template assigned will also inherit the template.”
Why Create Shared Layouts?
Shared layouts are a great way to organize special layouts for your site such as splash pages, unique page layouts, and layouts with particular advertising slots. Shared layouts can be created and applied not only to WordPress pages, but to any type of WordPress content, including a standard post, custom post types, even archives or other layouts in the WordPress layout hierarchy.
Shared Layout Best Practices
Names that Make Sense
Make sure that your shared layouts has a name that makes sense! The default will be something useless but unique, such as Template 1. Months down the road, who is going to remember which layout that is? Instead, ensure that your layout templates have useful names that denote the template function or a unique feature, such as “Hero Slider Page Layout” or “Gold Advertising Page Layout” or “Splash Page Layout.”
These names are going to be displayed in the WordPress backend as well as in the Visual Editor, so they should make sense to you—and any other content editors who may need to make use of them when curating or developing content for your website.
Mirroring Blocks or Wrappers
Remember, mirroring means you’re taking the entire original block to include all the block options! You have the option to mirror blocks, or entire wrappers (that includes the wrapper, the wrapper options, AND the blocks within the wrapper!).
More than likely, you’re using a layout template because you are deviating from the norm. In that case, maybe mirroring doesn’t make much sense. You won’t mirror your standard widget area, “Primary Sidebar,” when you need a unique sidebar for advertising.
Or perhaps you might be interested in mirroring select blocks but not an entire wrapper in that content area. Perhaps you want the same sidebar, but you need to fit in a few additional blocks? Don’t mirror the wrapper in this case; just mirror the specific blocks you want to copy.
So go ahead and mirror blocks or wrappers from other layouts, just make sure that you’re mirroring from a layout that has staying power—meaning a layout you aren’t going to demolish and delete in a few weeks! That can cause some very interesting, and unintended, results in your layout down the road.
Using a Shared Layout as a Holding Area for Blocks and Wrappers
We’ve seen some users creating shared layouts specifically to act as a sort of holding area for blocks with specific options.
Most often, this is seen with our users who are really planning ahead. They know they will have one or two wrappers that hold header elements that they’ll use throughout the site, as well as a few different content blocks, widget areas, and custom code blocks. So they put it all onto a separate shared layout, give all the blocks appropriate block aliases, and mirror the blocks on the layout template. It works out fine, since the block or wrapper options are mirrored but not the size, so the other layouts in the hierarchy can be set up as needed without worrying about fit.
Future edits to the blocks and wrappers are easy, because it’s all in one layout. No searching around to find the “original” content block to adjust the post meta.
This can be a great approach with two caveats:
- It can get really messy with several dozen blocks in one layout, especially when they are placed randomly throughout. If you take this approach, organize as best you can, and try to limit the blocks you place on a single layout template if you start to see the template getting bogged down and slow to load.
- Blocks can’t be mirrored on the same layout, so if you want to create two wrappers that each include a header block that you’d like the mirror to each other, you can’t—not in that same layout template, that is. Blocks can mirror blocks only from another layout.
Keep it simple! You don’t always need to create a shared layout. Shared layouts are great for when you need to reuse
a layout, but Headway provides you the option to customize for a single, specific layout for a reason: Your change isn’t always one that you’re going to be using over and over again throughout your site.