Basic settings

When you extend Page from your favorite bundle, you get basic support for a HTML page.
It is recommended to make a common template that extends Page.
Here you put site-wide settings, include common JS and CSS dependencies.
For basic site settings you override def siteSettings. It has the following fields:

NameMandatoryTypeDefault valueDescription
nameNoOption[String]NoneName of this site
faviconNormalNoOption[String]NoneFavicon of this site
faviconInvertedNoOption[String]NoneFavicon with alternative color, can be used in navbar for example

SiteSettings are usually defined in a common trait, for example:

package utils

 import Imports.Bundle.*

 trait MyPageTemplate extends Page {
   override def siteSettings = super.siteSettings
     .withName("example.com")
     .withFaviconNormal("favicon.jpg")
 }

Per-page settings are in the def pageSettings.
PageSettings has the following fields:

NameMandatoryTypeDefault valueDescription
titleNoStringchangemeTitle of this page
labelNoString<same as title>Label used for link to this page
languageNoStringenLanguage of this page
descriptionNoOption[String]NoneDescription of page content

Example of page definition:

package files
import utils.*

object Index extends MyPageTemplate {
  override def pageSettings =
    super.pageSettings
      .withTitle("Welcome!")
      .withDescription("My cool site")
}

Body content

If you really, really want to redefine content of the <body>, use the def bodyContent: Frag method.
Note that none of the <script>s will be included, you have to do all by yourself!
You can peek at the original implementation, copy-paste it and tweak it a bit.

The tag is roughly defined as follows:

body(
  bodyContent,
  inlineScripts..
)

and bodyContent:

frag(
  pageContent,
  inlineScripts..
)

See Page Content section.

All this hierarchy is to allow you to override only the parts you want. For example, override pageContent to define rough layout of the page: navbar, main content, footer, sidebars etc.

Page content

Next up is the def pageContent: Frag method.
Here is the content of your HTML page.
It will be embedded somewhere in the <body>, depending on your framework.

The pageContent is roughly defined as follows:

main(
  mainContent
)

Main content

Next up is the def mainContent: Frag method.
Here is the main content of your HTML page.
It will be embedded somewhere in the pageContent.

Meta content

The def metaSettings defines all things <meta>:

  • charset
  • viewport
  • og tags
  • etc

Head content

If you really, really want to redefine content of <head>, use the def headContent: Frag method.
Note that none of the <meta>, <title>.. will be included, you have to all by yourself!

Manifest

The def manifest contains the manifest of your website, it is useful for PWAs (Progressive Web Apps).
You can serialize it like this:

import ba.sake.tupson.*

println(MyPage.manifest.toJson)