0

I am trying to build a custom theme in drupal. I have two page files:

page.html.twig
page--front.html.twig

both files have the same code:

<div class="container">
    {{ page.myheader }}
    <div class="row">
        <div class="col-md-3">
            {{ page.sitebrand }}
        </div>
        <div class="col-md-6">
        </div>
        <div class="col-md-3">

The Problem: I see the blocks in all the pages except the front page.

by the way: I did set my front page as this: enter image description here I created a simple page with 'front' alias.

Is this cousing a problem?

The question: What am I doing wrong? How can make different display in the front page?

full page--front.html.twig

<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>

<div class="container">
    {{ page.myheader }}
    <div class="row">
        <div class="col-md-3">
            {{ page.sitebrand }}
        </div>
        <div class="col-md-6">
        </div>
        <div class="col-md-3">

xxx dagfv

            <button type="button" class="btn btn-lg btn-block">
                Default
            </button>
            <div class="btn-group">

                <button class="btn btn-default">
                    Action
                </button>
                <button data-toggle="dropdown" class="btn btn-default dropdown-toggle">
                    <span class="caret"></span>
                </button>
                <ul class="dropdown-menu">
                    <li>
                        <a href="#">Action</a>
                    </li>
                    <li class="disabled">
                        <a href="#">Another action</a>
                    </li>
                    <li class="divider">
                    </li>
                    <li>
                        <a href="#">Something else here</a>
                    </li>
                </ul>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-md-12">
            <nav class="navbar navbar-default" role="navigation">
                {{ page.mainmenu }}
            </nav>
        </div>
    </div>

    <div class="row">
        <div class="col-md-3">
        </div>
        <div class="col-md-9">

        </div>
    </div>
    <div class="row">
        <div class="col-md-2">
        </div>
        <div class="col-md-2">
        </div>
        <div class="col-md-2">
        </div>
        <div class="col-md-6">
        </div>
    </div>

    <div>
        {{ page.content }}
    </div>
</div>
</body>
</html>
  • Could you paste the complete page--front.html.twig? Did you see the blocks before creating the separate page--front.html.twig? – Wim Mostrey Jan 8 '17 at 7:56
  • added the full page--front.html.twig code in the question above. I made some tests and i know that the site reads the the front.twig file. I just dont understand why the blocks are not showing. Does it have anything to do the the naming of the blocks placeholders in the file? maybe I an doing something wrong calling the front page in the configuration area. – DavSev Jan 8 '17 at 8:01
  • Try giving your node a different path, for example "frontpage" and keep the page--front.html.twig as-is. – Wim Mostrey Jan 8 '17 at 8:06
  • Created a new page called /frontpage. I entered the page and I see the blocks. I've replaced the front page in configuration->basic site settings so now the /frontpage is the index. entered the main page. don't see any blocks... – DavSev Jan 8 '17 at 8:13
  • 1
    Clear cache to allow Drupal to register the new theme file – LittleCoding Jan 8 '17 at 8:13
0

You have two problem.

  1. page--front.html.twig is special suggestion template for front page. Any url set to front page always use this template => You don't need set alias for this.Just set page you want to front page.
  2. Don't add html tag to page template. The tree of template is html=>page=>region=>block... Html tag exited in template html.html.twig.

And more you can setting twig debug to see current home page use template?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.