Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Duplicate navigation when using "includes" with Jade/Node

Duplicate navigation when using "includes" with Jade/Node

Problem

I have a one page website that I would like to keep but I also need individual sections to be viewed as independent pages. I'm using Jade with Node and everything is working fine until I start including files/blocks.

base.jade

!!! 5
  head
  body
    .nav
      // menu
    block content

index.jade

extends layout/base

block content
  p
   | This is the index page.
  include about

about.jade

extends layout/base

block content
  p
   | This is the about page.

What I'm trying to do is use the index page to display all of my pages and then have the individual pages extend the base.jade file. What's happening is I'm getting multiple navigation bars on index.jade because I'm extending base.jade twice. I'm a little stuck and feel like I'm missing something simple here.

Any help is appreciated, thank you.

Problem courtesy of: Devin McInnis

Solution

the file you include should only have the content portion such as

about-content.jade

p
   | This is the something about the site.

then index.jade is

extends layout/base

block content
  p
   | This is the index page.
  include about-content

and about.jade

extends layout/base

block content
  p
   | This is the about page.
  include about-content
Solution courtesy of: Pascal Belloncle

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

Duplicate navigation when using "includes" with Jade/Node

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×