Setting the DocType

Lift currently defaults to the XHTML 1.0 Transitional DocType for all generated pages. If you’re producing content in another version of HTML, you’ll want to set the appropriate DocType. You can do this persistently , or on a page-by-page basis.

Persistently setting the DocType

To set a custom DocType persistently, place the following in your Boot.scala , in the Boot class:

// set DocType to HTML5
LiftRules.docType.default.set( => r match {
  case _ if S.skipDocType => Empty
  case _ if S.getDocType._1 => S.getDocType._2
  case _ => Full
})

The available DocType options, as declared in the net.liftweb.http.DocType object, are:

Use any of the above in place of html5 in the code example above.

Setting the DocType for a given page

In the body of your method, include a variation of the following:

// set DocType for this response to HTML5
S.setDocType(Full)

The S object represents the current HTTP request and response.