Download

@website global variable

Every website contains some useful data under the @website global variable.

  • @website.url - site URL (it can contain index.html at the end in some cases - such as during website settings or in preview mode),
  • @website.baseUrl - site URL without index.html at the end
  • @website.rootUrl - alias for @website.baseUrl,
  • @website.tagsUrl - URL for the page with all tags,
  • @website.searchUrl - URL for the search page,
  • @website.errorUrl - URL for the error page,
  • @website.assetsUrl - URL for the assets directory of the theme (assets directory is defined in the theme config.json file),
  • @website.mediaFilesUrl - URL to the /media/files/ directory,
  • @website.pageUrl - URL of the currently displayed page,
  • @website.ampUrl - URL for the AMP version of the page (empty when AMP is disabled),
  • @website.name - site name,
  • @website.logo - site logo (alias for @config.basic.logo),
  • @website.logoSize - object with size of the logo in pixels - you can access width via @website.logoSize.width and height via @website.logoSize.height
  • @website.lastUpdate - timestamp of the last website render,
  • @website.contentStructure - object with structure of the website content (explained below),
  • @website.language - language code of the website language based on the website settings. Can be used in the lang attributes.
  • @website.postsOrdering - ordering of the posts on the listings (returned values: asc or desc), can be used for proper handling of the pagination ordering.

Content structure

The @website.contentStructure global variable contains the following object:

{
   posts: [post item],
   tags: [{
       tag item
       posts: [the same structure as in the posts above]
   }],
   authors: [{
       author item
       posts: [the same structure as in the posts above]
   }]
}  

This is useful if you want to generate some parts of your website automatically such as the main menu structure which are updated with new posts/tags/authors.

What are you waiting for?

Start building your site today.

  1. 1 Download Publii
  2. 2 Write your content
  3. 3 Publish your site
Create website