Back to top

Config

Add additional meta tags, link tags and script tags to page.

This fragment, unlike most other fragments, doesn’t render anything (so it wouldn’t need a weight variable).

If a config fragment is registered on a page, it’s configuration values are considered and added before the </body> tag (default) or at the end of <head> tag.

Acceptable config types are meta, icon, css and js. Each config can contain either html or resource (except for meta type which only accepts html and is added as a <meta> tag to the <head> of the document). resource can accept either a file path (relative to static/ directory) or a URL. This will then be added to a <link> or <script> tag based on the type value.

This example adds Bootstrap color scheme (link) to the page.

You can use this fragment to add custom scripts for different pages, or different sections or all of the pages together (through the _global directories).

Code
+++
fragment = "config"

[[config]]
  type = "css" # Acceptable values are icon, meta, link, css, js. Default is empty. Would not add anything on empty.
  # block = true # If set to true, would inject the code to the <head> tag. Default is false
  html = "<link rel='stylesheet' href='https://bootswatch.com/4/united/bootstrap.min.css'>" # HTML code injected directly to the page. Default is empty.
  # file = "" # Path to file, can be on page or in static/ directory. Default is empty.

[[config]]
  type = "js"
  # block = true # Default is false
  html = """
  <script>
    document.getElementsByTagName("body")[0].style.cursor = "url('http://wiki-devel.sugarlabs.org/images/e/e2/Arrow.cur'), auto";
  </script>
  """
+++

Documentation

Variables

config

type: array of objects&

config.type

type: string
accepted values: meta, css, js, icon

Type of the configuration.

config.block

type: boolean
default: false

This value determines whether css, js or icon configuration is added to the <head> tag or at the end of the <body> tag of the document. If a url or code is added to the <head> or before any part of the HTML, it would block the render and runtime of the rest of the document.

config.resource

type: string

Path to the resource. Can accept a file name (relative to static directory) or a url.

If config.type is set to any of css, js or icon, either config.resource or config.html should be provided.

config.html

type: string

HTML code injected directly to the page.

If config.type is set to any of css, js or icon, either config.resource or config.html should be provided.

[Global variables]/docs/global-variables/) are documented as well and have been omitted from this page.