Skip to main content

Reusable Layouts

warning

Do not copy entire demo pages as a long-term strategy. Extract reusable sections and align them with your tokens/presets to prevent drift.

Reusable Layouts Explained

Reusable assetWhat it isWhere it often lives
Block pattern/sectionReusable block layoutBlock editor patterns
ElementConditional header/hook/layoutGP Premium Elements
Media assetsImages/icons used by templateswp-content/uploads/
Template cache filesImport-related artifactswp-content/uploads/generatepress/ (often)

Why It Matters

  • Reuse reduces build time and prevents inconsistent pages.
  • Components can be versioned and documented.
  • A component library helps teams collaborate.

How It Works

You identify a repeated layout, extract it into a reusable section (pattern/element), and align it with global tokens/presets.

flowchart LR
DEMO[Imported demo pages] --> EXTRACT[Extract section]
EXTRACT --> LIB[Component library]
LIB --> REUSE[Reuse across pages]

Practical Walkthrough

Step 1: Inspect GeneratePress Upload Artifacts (If Present)

inspect-generatepress-uploads.sh
cd /var/www/html
ls -lah wp-content/uploads/generatepress 2>/dev/null | head -n 80 || true

Step 2: Inventory Elements (If Used)

inventory-elements.sh
cd /var/www/html
wp post list --post_type=gp_elements --fields=ID,post_title,post_status --format=table 2>/dev/null || true

Step 3: Identify Reusable Page Sections (Content Audit)

list-pages-for-audit.sh
cd /var/www/html
wp post list --post_type=page --fields=ID,post_title,post_status --format=table | head -n 40

Step 4: List Reusable Blocks (If Used)

Reusable blocks/pattern content may be stored as the wp_block post type.

list-reusable-blocks.sh
cd /var/www/html
wp post list --post_type=wp_block --fields=ID,post_title,post_status --format=table 2>/dev/null | head -n 40 || true

Practical Examples

Example 1: Extract a Hero Section

Turn a page-specific hero into:

  • A Block Element (if conditional)
  • A pattern (if reused across pages)

Create one CTA section and reuse it across:

  • Services pages
  • Blog posts
  • Landing pages

Example 3: Component Naming Convention

TypeExample name
PatternSection: Pricing CTA
Block elementBlock: Home hero
Hook elementHook: Top notice
Layout elementLayout: Landing no sidebar

Example 4: Turn a One-Off Section into a Reusable Block

Workflow:

  1. Copy the section into a reusable block/pattern.
  2. Remove inline styles and replace with tokens/presets.
  3. Reuse it on two pages.

Best Practices

PracticeWhy
Standardize names and intentFaster audits
Reuse presets/tokensPrevents drift
Keep components smallEasier performance control
Document where components are usedPrevents accidental deletes
Prefer reuse over duplicationPrevents drift
Keep a component indexHelps teams find the right section
Make one "source" componentPrevents multiple near-duplicates

Troubleshooting

SymptomCauseFix
Component shows in wrong placeRule mismatchTighten display rules and re-test
Reused section looks differentLocal overridesReset per-page overrides and use presets
Assets missingMedia not importedRe-import media or relink assets
Reusable block not foundPost type disabledConfirm wp_block exists and you have permissions

Hands-On

  1. Pick one repeated section from an imported template.
  2. Extract it into a reusable pattern or element.
  3. Reuse it on two pages and confirm output is identical.
  4. List reusable blocks with WP-CLI and export an inventory for your runbook.
  5. Document where the component is used (URLs or page IDs).

Quick Reference

reusable-layouts-cheatsheet.sh
cd /var/www/html
ls -lah wp-content/uploads/generatepress 2>/dev/null | head
wp post list --post_type=page --fields=ID,post_title,post_status --format=table | head

What's Next