Skip to content

Add pages and a shared menu

Markdown

For builders who have made a site. It covers adding a page, changing the header every page shares, linking between pages, and giving a page its own layout. At the end, Saltmere Marina has an About page and every page’s header links to it.

A page is an HTML file. Its path in the site’s folder is its web address:

File Address
index.html /
about.html /about
services/winter-storage.html /services/winter-storage
services/index.html /services

Make about.html:

---
layout: default
title: About the marina
---
<h1>About the marina</h1>
<p>Saltmere Marina has 140 slips on the south shore of Nova Scotia.
The Doucet family has run it since 1987.</p>
<img src="/photos/dock.jpg" alt="The main dock at sunrise">

The lines between the two --- lines are the page’s front matter, its settings. layout: default wraps the page in the site’s main layout, _layouts/default.html.

Put a JPEG photo of your own at photos/dock.jpg in the folder. Every file is published at its own path, except files and folders whose names start with an underscore or a dot, and AGENTS.md and README.md in the top folder. So the photo is at /photos/dock.jpg. When the Website Strategy platform builds the site, it makes smaller copies of each photo for phones and lists them on the img tag for you.

A page can hold anything a browser runs: its own style and script tags, CSS animation, a 3D scene. Scripts and style sheets can load from the site’s own files, from the shared libraries the platform serves, such as three.js, or from any other https address. When a page loads them from another domain, ws push, which publishes the site (part 6), lists the domains, so you see them.

Check it:

Terminal window
ws preview
Built 2 pages.
Private preview, open to anyone with this link until November 20:
https://saltmere-marina--k7f3.sitepeek.page/?key=Hn4pX7rKq2Lw9TzB3mVc8d

Open /about on the preview. ws preview keeps the same link each time, so a phone that opened the preview before still has it.

The header lives in one file, _includes/header.html, and the layout puts it on every page. Add the About link there once:

<header>
<a href="/" class="name">{{ site.name }}</a>
<nav>
<a href="/">Home</a>
<a href="/about">About</a>
</nav>
</header>

Run ws preview again. Both pages now show the link.

A file in the includes folder can read the site’s name (site), the current page’s settings (page) and the site’s data (data, in part 4). To give it anything else, pass it by name:

{% render 'button.html', label: "Book a slip", href: "/book" %}

Inside _includes/button.html, those values are {{ label }} and {{ href }}.

3. Give a page its own layout, if it needs one

Section titled “3. Give a page its own layout, if it needs one”

Most sites need only _layouts/default.html. A page that should look different, such as a full-screen landing page, can have its own layout. Make _layouts/landing.html, with {{ content }} where the page should go, and set layout: landing in the page’s front matter. A page with no layout line is not wrapped in any layout, though its Liquid tags still run.

Section titled “Link to your own pages with relative paths”

Link to the site’s own pages and files with paths that start with a slash, such as /about or /photos/dock.jpg, never with the site’s full address. The site’s address changes when the business buys it and gets its own domain, and a full address would still point at the old one.

A link, form, redirect, image, style sheet url() or <meta http-equiv="refresh"> that names the site’s own domain is a warning on a sample, a site the business has not bought yet. On a bought site it stops the publish, and names the file and line.