How would I pull the content of a CMS page into a static block?

Stefan Bogdanescu
Founder & Senior Architect · 6 July 2026

Pulling CMS Page Content into Static Blocks: A Developer’s Guide

Pulling dynamic content from your CMS into static blocks can be a powerful way to create reusable components in your Laravel application. This allows you to manage your content in one place while displaying it anywhere on your site.

Understanding CMS Pages and Static Blocks

In the Laravel ecosystem, CMS pages are typically managed by packages like Laravel 8 Cms or LaraCasts’ Page Manager. These allow you to create and manage content pages separate from your blade templates.

Static blocks, on the other hand, are reusable code snippets that can be inserted anywhere in your application. They are stored in files like views/components/block-name.blade.php.

Pulling CMS Page Content into Static Blocks

To pull the content of a CMS page into a static block, you’ll need to use Laravel’s service provider and controller functionality.

  1. First, ensure your CMS package is properly installed and configured according to its documentation on Laravel Company.

  2. Create a new component for your static block:

// resources/views/components/block-name.blade.php

<div>
    <!-- Block content will be inserted here -->
</div>
  1. In your controller, use the service provider to retrieve the CMS page’s content and pass it to the view.
// app/Http/Controllers/PageController.php

use App\Models\CmsPage;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\View;

public function show(Request $request)
{
    // Retrieve the CMS page by ID or slug as needed
    $page = CmsPage::find(1);

    if (!$page) {
        return view('404');
    }

    // Pass the page content to a view variable
    View::share('pageContent', $page->content);

    // Return the static block view with the shared data
    return view('components.block-name');
}

In this example, the CmsPage model and its find() method are used to retrieve the desired page. Adjust these lines according to your specific CMS package’s naming conventions.

  1. In your blade template for the static block, use Laravel’s {{ $pageContent }} syntax to display the shared content:
// resources/views/components/block-name.blade.php

<div>
    {!! $pageContent !!}
</div>

The {!! !!} tags are used here to output the raw HTML content of the CMS page, ensuring that any formatting or embedded code is preserved.

  1. Finally, include your static block in any blade templates where you want to display this content:
// resources/views/home.blade.php

@extends('layouts.app')

@section('content')
    <div class="container">
        <!-- Other content -->
        @include('components.block-name')
        <!-- More content -->
    </div>
@endsection

Conclusion: A Powerful Content Management Strategy

Pulling CMS page content into static blocks provides a clean separation of concerns, allowing you to manage your content in one place while maintaining the flexibility to reuse it anywhere in your application.

This approach ensures that your code remains organized, maintainable, and easy to update. It also allows for greater consistency across your website, as all pages can draw from the same centralized repository of content.

Remember to check out Laravel Company for more tips on efficient Laravel development, including best practices and advanced techniques for working with CMS packages in Laravel 8.

Our network