Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP Building Websites with PHP Slim Basics & Twig Templates Layouts with Twig

Cannot get my main.twig file to render within the browser?


I have checked the main.twig file to ensure all content blocks have been inserted between the proper tags w the correct syntax. However when I preview within the browser, my page does not render? Here is my source code below, any suggestions?

  {% block head %}
    <meta charset="utf-8">
    <title> {% block title %}Ralph Waldo Emerson  {% endblock title %}</title>
    <meta name="description" content="Ralph Waldo Emerson">
    <meta name="author" content="Treehouse">
    <link href='http://fonts.googleapis.com/css?family=Roboto:400,700' rel='stylesheet' type='text/css'>
    <link rel="stylesheet" href="css/master.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
    <script src="js/global.js"></script>
  {% endblock head %}

  <div id="feedback" class="success">
    <p>You're reading all about Emerson.</p>

    <h1>Ralph Waldo Emerson</h1>
      <a href="index.html" class="selected">About</a>
      <a href="contact.html">Contact</a>

  <div class="emerson">
     {% block hero %}
    <img src="images/emerson.jpg" alt="Picture of Ralph Waldo Emerson"> 
    {% endblock hero %}

   {% block content %}
  {% endblock content %}

    {% block footer %}
      <p>A project from <strong><a    href="http://teamtreehouse.com">Treehouse</a></strong></p>
        <a href="index.html" class="selected">About</a>
        <a href="contact.html">Contact</a>
    {% endblock footer %}

6 Answers


I hear ya.

I've been staring at the white screen of death (PHP's least useful feature) for about an hour trying solve the same issue. If you are getting a blank page like I was, your issue is probably in the index.php file.

The code above looks fine. If you post your index.php code, I'll take a look at it.

What's happening when you load the page?

Hello Steve,

I have been fixated on the my index.php file, but have not been able to identify the exact bug occurring there. When I load the page it just continues to render the blank white page as opposed to the content blocks. Here is the code for reference:


require 'vendor/autoload.php';

use Monolog\Handler;
use Monolog\Handler\StreamHandler;

//$log = new Monolog\Logger('name');
//$log->pushHandler(new StreamHandler('app.log', ::WARNING));
//bool date_default_timezone_set ( 'America/Jamaica');

  $app = new \Slim\Slim(
  'view' => new \Slim\Views\Twig()

$view = $app->view();
$view->parserOptions = array(
    'debug' => true,

$view->parserExtensions = array(
    new \Slim\Views\TwigExtension(),

$app->get("/",function() use($app){
  $app-> render('about.twig');

$app->get("/contact",function() use($app){
  $app-> render('contact.html');

$app->get('/hello/:name', function ($name) {
    echo "Hello, $name";


Hey Justin,

Are you running this on your own PHP installation, or on Workspaces? I was having some issues getting the page to load on my own local PHP installation (via AMPPS on OSX) because the 'ctype' extension was disabled by default.

After stopping the server, enabling 'ctype.so', and then re-starting the server, it seems to be working fine. Not sure if that will help you, but I thought it was worth mentioning.

Hey Gabe,

I was running the php through preview in workspaces. I'm not entirely sure what the issue is. I will try using MAMP and see what kind of results I get. Thanks for the tip!

Bhavesh Bansal
Bhavesh Bansal
13,810 Points

Thanks Gabe . I was also facing the same issue with AMPPS in OSX . Your tip of enabling ctype.so solved the issue. For others who are also facing same issue with AMPPS just follow the below step to find ctype.so Enable PHP Extension ctype from AMPPS Application -> PHP Tab -> PHP Extension. (Src http://goo.gl/aflxF5)

Having the same issue with rendering the page. Here is the link to the workspace. https://w.trhou.se/bb48pdaazf

Purvi Agrawal
Purvi Agrawal
7,960 Points


I am getting a white screen too when previewing through workspace. The code looks same as in the video. Not sure what the issue is. Any inputs ?

Michael O'Kane
Michael O'Kane
5,896 Points


I'm having the same problem and have checked my code against the video and the installation and its not working as expected.

Any pointers would be appreciated.

Purvi Agrawal
Purvi Agrawal
7,960 Points

Hello, So I was able to solve the issue by changing the Jquery tag to "://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"

It worked for me. U might have the same issue. Just try this technique once n if it works.. Then Yahooo !!

Workspaces doesn't like PHP for some reason. To help solve the problem, set up a local server like XAMPP (Windows) or MAMP (OSX) on your computer.