# View does not render Template

**URL:** <https://discourse.cakephp.org/t/view-does-not-render-template/2682>\
**Category:** Need Help\
**Created:** [June 8, 2017, 3:11am UTC](https://discourse.cakephp.org/t/view-does-not-render-template/2682 "2017-06-08T03:11:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![juarezfrancojr](https://avatars.discourse-cdn.com/v4/letter/j/c67d28/32.png) [@juarezfrancojr](https://discourse.cakephp.org/u/juarezfrancojr)\
**Post date:** [June 8, 2017, 3:11am UTC](https://discourse.cakephp.org/t/view-does-not-render-template/2682/1 "2017-06-08T03:11:23Z")

</div>

I create IndexView and extends AppView, the method render is called, but my template don’t render, i try

```
public function render($view = null, $layout = null) {
	$this->layout = 'index';
    echo 'hello'; // It works but the page is blank
}

```

In my controller I call  
`$this->viewBuilder()->className('Index')`

---

<div class="post-metadata">

**Author:** ![rrd](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/rrd/32/113_2.png) [@rrd](https://discourse.cakephp.org/u/rrd)\
**Post date:** [June 8, 2017, 1:43pm UTC](https://discourse.cakephp.org/t/view-does-not-render-template/2682/2 "2017-06-08T13:43:10Z")

</div>

What version of CakePHP? What do you want to achive? Why do you need the dedicated render method?

---

<div class="post-metadata">

**Author:** ![juarezfrancojr](https://avatars.discourse-cdn.com/v4/letter/j/c67d28/32.png) [@juarezfrancojr](https://discourse.cakephp.org/u/juarezfrancojr)\
**Post date:** [June 8, 2017, 3:56pm UTC](https://discourse.cakephp.org/t/view-does-not-render-template/2682/3 "2017-06-08T15:56:18Z")

</div>

Version 3.4.  
How does the view work? Isn’t it between controller and template?  
I want to treat injections in template of CSS and JS, footers and headers.

Correct me if I’m wrong

My template

```
<!DOCTYPE html>
<html lang="pt-br">
<head>
    <title>Title</title>
    <link href="/favicon.ico" type="image/x-icon" rel="shortcut icon"/>
    <?php
    echo $this->Html->charset('UTF-8');
    echo $this->Html->meta('description', 'Description');
    echo $this->Html->meta('viewport', 'width=device-width, initial-scale=1');
    echo $this->fetch('meta');
    echo $this->fetch('css');    
    ?>
</head>
<body id="home">
    <?php
    echo $this->Html->script(['facebook.min.js','google.min.js']);
    // code html here ...
    echo $this->fetch('header'); // inject header
    // code html here ...
    echo $this->fetch('content'); // inject body
    // code html here ...
    echo $this->fetch('footer');
    echo $this->fetch('script'); 
    ?>
</body>
</html>
```

---

<div class="post-metadata">

**Author:** ![rrd](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/rrd/32/113_2.png) [@rrd](https://discourse.cakephp.org/u/rrd)\
**Post date:** [June 9, 2017, 8:02am UTC](https://discourse.cakephp.org/t/view-does-not-render-template/2682/4 "2017-06-09T08:02:18Z")

</div>

Your example is a layout, located at `/src/Template/Layout`

`$this->fetch('content');` will display for example `/src/Template/Posts/index.ctp`

In `/src/Template/Posts/index.ctp` you can add additional css and js files like this  
`echo $this->Html->script('your_extra_js.js', ['block' => true]);`

Is this what you need?
