Custom template does not render within index.php in Sage 10


I am having some trouble with rendering a custom template on a custom route. The custom template does not seem to render within de: web/app/themes/sage/index.php

I except the template to render within in the:

<?php echo view(app('sage.view'), app(''))->render(); ?>

I am running the following code in my service provider:


namespace App\Providers;

use Illuminate\Support\Facades\Route;
use Illuminate\Support\ServiceProvider;

class EventServiceProvider extends ServiceProvider
     * Register services.
     * @return void
    public function register()

     * Bootstrap services.
     * @return void
    public function boot()
        Route::get('/event/{slug}', function ($slug) {
            $post = get_page_by_path($slug, OBJECT, 'tribe_events');

            if(empty($post)) {
            return view('single-event', [
                'post' => $post

The template will render, however, I am missing all the html content of index.php such as the where all the css and js files are rendered.

I could solve it by adding all the html content in a custom template and add it in there, but that is not a clean way to solve the problem.

Let me know if anyone has run into this issue before or has solved it.

I’m trying it like this, but I can’t guarantee if it’s the correct approach as I’m new to Sage 10

Put your html wrapper (from the original index.php) in layouts/html.blade.php and add a yield(‘app’) where the render() function was

In layouts/app.blade.php wrap it in a @section(‘app’)

Make your app blade file @extends(‘layouts.html’)

In the main index.php strip out all the html and just have the one line that echoes the render()

Now all custom routes that view() a custom template will include the html headers if you extend

Again note as per the experimental router notes, you won’t get eg Yoast data for custom routes as it’s bypassing the proper Wordpress flow here for these routes (ie they don’t exist as part of the normal Wordpress template routing)

Let me know if this works for you. Again it was only a quick test on a new Sage 10 theme and I’ve not checked it works for everything

In general it seems better not to use custom routes other than for eg Ajax etc and instead maybe make sure you’re setting up proper template redirect actions etc and holder pages within the CMS

In your case though, why not set up “event” as a custom post type slug and just let Wordpress do the job?