Embed the same menu in every page

If you wanted to create another page, you would have to edit the menu on top of all pages. That's error prone, let's fix that. We'll move the menu code into a single file and use it on every page.

Open the IDE, navigate into the root file and create the file /src. No need to set a type on it. This will be just a container to hold our menu app.

 

src-file.png

 

Navigate into it and create the file /src/menu.

 

src-menu-file.png

 

Set its type to sjs-4et,

 

src-menu-file-type.png

 

and add HTML code responsible for the menu to its body:

 

 

src-menu-file-body.png

 

In all the page files, replace the menu's code above with this:

 

 

use-central-menu-app-on-all-pages.png

 

Once you are done with that, you can edit the menu centrally. Let's add a new page so we can enjoy our success!

In the IDE, turn on the Toolchain. This will allow us to select files and access the contextmenu on them.

 

turn-on-the-toolchain.png

 

Right click the file /contact and choose Duplicate.

 

contextmenu-duplicate-page.png

 

Rename it to /blog. To rename it, the text editor on the right needs to be closed. You will find a pencil button on the right side of the IDE, click to rename the file.

 

rename-file-in-the-IDE.png

 

Change the body of this new /blog file to display Blog.

 

change-blog-files-body.png

 

Finally, edit the /src/menu file: add a new menu entry pointing to the /blog file. Note how we are only updating a single file here, not multiple files!

 

updating-the-menu.png

 

Visit your site and click around your pages. Congratulations, your multi-page website is taking shape!