All right. 1
Spoiler warning. I'm going to reveal the answer. 2
Inside the EJS documentation you might remember that I pointed you to the part that says layouts. And this 3
allows you to include headers and footers by using this syntax and the key word include. So we can use 4
this syntax to include our header and footer. 5
So let's go ahead and implement it in our file as well. 6
Inside our home. 7
ejs we're going to delete everything other than our h1 and our paragraph tag because we've got everything 8
inside our header and footer. 9
Now instead of those bits of HTML code we're going to use our EJS layout syntax which is angle bracket, 10
percentage sign, minus sign or dash and then we use the keyword include and we open up a set of parentheses. 11
And then inside the parentheses we specify the name of the file that we want to include which in this 12
case will be header because we have a file called header. 13
ejs inside our views directory. And then we close off our EJS tag with again a minus sign, percentage 14
and angle bracket. 15
And let's go ahead and copy that down here so that we can do the same for our footer. 16
Now this word has to match the EJS file that you've got inside your views folder 17
in order for it to work. 18
So now that we've got that code in there let's go ahead and hit save. 19
And once you refresh your page this is what you should see. 20
Now if you had a search for how to do this and you come across some answers you might realize that there's 21
quite a few ways of creating that syntax. 22
For example in this case, they've simply just said angle percentage include and then the path of the 23
file from the views folder. 24
Or in this case over here you've got a dash in the front and no dash at the back and there's no parentheses. 25
So all of these different methods work and the method that we should try and follow is the one that's 26
used inside the documentation. 27
But for our challenges sake it doesn't matter which method you chose to use as long as you get the end 28
result and you've achieved the goal then you've successfully completed the challenge. 29
All right so here's onwards to challenge 4.