Third-party imports

Description#


By default in the theme, it is possible to import libraries or third-party code into the generated html page, using the website configuration.

The several types of imports managed by the theme are the following ones:

Import typeComment
SCSS files (.scss)
  • Imported in <head> tag as <link rel="stylesheet" type="text/css"> after being converted as CSS by Hugo , grouped and minified in css/main.css file
  • Paths used for the SCSS conversion :
    • assets/bulma
    • assets/scss
CSS files (.css)
  • Imported file by file in <head> tag as <link rel="stylesheet" type="text/css"> and minified
Javascript files (.js)
  • Imported file by file at the end of the <body> tag as <script type="text/javascript"></script> and minified
Javascript modules (.js)
  • Imported file by file at the end of the <body> tag as <script type="module"></script> and minified
Files to import must be defined as Hugo assets

Define third-party imports#


To define a file to import you must use the following configuration (Cf. highlighted lines below):

hugo.toml ([params] section)
  1[params]
  2  # Website logo file paths
  3  logo                    = "images/logo.png"
  4  logoTouch               = "images/logoTouch.png"
  5  # Image file path displayed during a 404 error
  6  image404                = "images/404.gif"
  7  # Favicon website file path
  8  favicon                 = "images/favicon.png"
  9  # Default layout used for the homepage
 10  homeLayout              = "onboarding"
 11  # Site content order (https://gohugo.io/templates/lists/#order-content)
 12  siteContentOrder        = "weight"
 13  # Activate/Deactivate the table of contents globally (sitewide)
 14  toc                     = true
 15  # Activate a global banner on all website pages
 16  globalBanner            = true
 17  # Curent version of the website
 18  currentVersion          = "latest"
 19  # Url of the latest version of the website
 20  latestVersionUrl        = "https://jgazeau.github.io/shadocs/"
 21  # Activate dark mode by default
 22  darkMode                = true
 23  # Enforce Link resolution using relref function (https://gohugo.io/content-management/cross-references/)
 24  enforceRefrelLinks      = true
 25  # Disable "Print" button in navbar
 26  navbarPrintEntry        = false
 27  # Disable "QR code" button in navbar
 28  navbarQRCodeEntry       = false
 29  # Disable "Shortcuts" button in navbar
 30  navbarSchortcutsEntry   = false
 31  # Disable "About" button in navbar
 32  navbarInfo              = false
 33  # Keyboard shortcuts list
 34  # For each shortcut following keys must be sets:
 35  # - keys     = [Keyboard shortcuts table](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values)
 36  # - function = "Javascript function name to call by the shortcut"
 37  [params.navbar.shortcuts]
 38    # Example shortcut definition
 39    [params.navbar.shortcuts.example]
 40      keys     = ["Shift","1"]
 41      function = "scExample"
 42  # Taxonomies list
 43  # For each taxonomy following keys can be sets:
 44  # - icon = "Fontawesome classes associated to the taxonomy"
 45  [params.taxonomies]
 46    [params.taxonomies.categories]
 47      icon = "fa-solid fa-table-cells"
 48  #
 49  # Assets list (https://gohugo.io/hugo-pipes/resource-from-template/) to include
 50  # Managed assets:
 51  # - css                   = [List of CSS files]
 52  # - js                    = [List of javascript files]
 53  # - jsModules             = [List of javascript modules]
 54  # - fencedcodes.css       = [List of CSS files to includes when the associated language of fenced code exist in the page content]
 55  # - fencedcodes.js        = [List of javascript files to includes when the associated language of fenced code exist in the page content]
 56  # - fencedcodes.jsModules = [List of javascript module files to includes when the associated language of fenced code exist in the page content]
 57  # - shortcodes.css        = [List of CSS files to includes when the associated shortcode exist in the page content]
 58  # - shortcodes.js         = [List of javascript files to includes when the associated shortcode exist in the page content]
 59  # - shortcodes.jsModules  = [List of javascript module files to includes when the associated shortcode exist in the page content]
 60  #
 61  [params.includes]
 62    css = [
 63      "css/file1.css",
 64      "css/fileX.css"
 65    ]
 66    js = [
 67      "js/file1.js",
 68      "js/fileX.js"
 69    ]
 70    jsModules = [
 71      "js/modules/file1.js",
 72      "js/modules/fileX.js"
 73    ]
 74  [params.includes.fencedcodes.css]
 75    fencedcode1 = [
 76        "css/fencedcodes/fencedcode1.css"
 77      ]
 78    fencedcodeX = [
 79        "css/fencedcodes/fencedcodeX.css"
 80      ]
 81  [params.includes.fencedcodes.js]
 82    fencedcode1 = [
 83        "js/fencedcodes/fencedcode1.js"
 84      ]
 85    fencedcodeX = [
 86        "js/fencedcodes/fencedcodeX.js"
 87      ]
 88  [params.includes.fencedcodes.jsModules]
 89    fencedcode1 = [
 90        "js/fencedcodes/modules/fencedcode1.js"
 91      ]
 92    fencedcodeX = [
 93        "js/fencedcodes/modules/fencedcodeX.js"
 94      ]
 95  [params.includes.shortcodes.css]
 96    shortcode1 = [
 97        "css/shortcodes/shortcode1.css"
 98      ]
 99    shortcodeX = [
100        "css/shortcodes/shortcodeX.css"
101      ]
102  [params.includes.shortcodes.js]
103    shortcode1 = [
104        "js/shortcodes/shortcode1.js"
105      ]
106    shortcodeX = [
107        "js/shortcodes/shortcodeX.js"
108      ]
109  [params.includes.shortcodes.jsModules]
110    shortcode1 = [
111        "js/shortcodes/modules/shortcode1.js"
112      ]
113    shortcodeX = [
114        "js/shortcodes/modules/shortcodeX.js"
115      ]

Define third-party imports for shortcodes#


The theme also offers the possibility to import libraries or third-party code associated with a shortcode. These files will be imported only if the shortcode is used in the current page, therefore reducing the loading time of the page.

To define a file to import, associated with a shortcode, you must use the following configuration (Cf. highlighted lines below):

hugo.toml ([params] section)
  1[params]
  2  # Website logo file paths
  3  logo                    = "images/logo.png"
  4  logoTouch               = "images/logoTouch.png"
  5  # Image file path displayed during a 404 error
  6  image404                = "images/404.gif"
  7  # Favicon website file path
  8  favicon                 = "images/favicon.png"
  9  # Default layout used for the homepage
 10  homeLayout              = "onboarding"
 11  # Site content order (https://gohugo.io/templates/lists/#order-content)
 12  siteContentOrder        = "weight"
 13  # Activate/Deactivate the table of contents globally (sitewide)
 14  toc                     = true
 15  # Activate a global banner on all website pages
 16  globalBanner            = true
 17  # Curent version of the website
 18  currentVersion          = "latest"
 19  # Url of the latest version of the website
 20  latestVersionUrl        = "https://jgazeau.github.io/shadocs/"
 21  # Activate dark mode by default
 22  darkMode                = true
 23  # Enforce Link resolution using relref function (https://gohugo.io/content-management/cross-references/)
 24  enforceRefrelLinks      = true
 25  # Disable "Print" button in navbar
 26  navbarPrintEntry        = false
 27  # Disable "QR code" button in navbar
 28  navbarQRCodeEntry       = false
 29  # Disable "Shortcuts" button in navbar
 30  navbarSchortcutsEntry   = false
 31  # Disable "About" button in navbar
 32  navbarInfo              = false
 33  # Keyboard shortcuts list
 34  # For each shortcut following keys must be sets:
 35  # - keys     = [Keyboard shortcuts table](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values)
 36  # - function = "Javascript function name to call by the shortcut"
 37  [params.navbar.shortcuts]
 38    # Example shortcut definition
 39    [params.navbar.shortcuts.example]
 40      keys     = ["Shift","1"]
 41      function = "scExample"
 42  # Taxonomies list
 43  # For each taxonomy following keys can be sets:
 44  # - icon = "Fontawesome classes associated to the taxonomy"
 45  [params.taxonomies]
 46    [params.taxonomies.categories]
 47      icon = "fa-solid fa-table-cells"
 48  #
 49  # Assets list (https://gohugo.io/hugo-pipes/resource-from-template/) to include
 50  # Managed assets:
 51  # - css                   = [List of CSS files]
 52  # - js                    = [List of javascript files]
 53  # - jsModules             = [List of javascript modules]
 54  # - fencedcodes.css       = [List of CSS files to includes when the associated language of fenced code exist in the page content]
 55  # - fencedcodes.js        = [List of javascript files to includes when the associated language of fenced code exist in the page content]
 56  # - fencedcodes.jsModules = [List of javascript module files to includes when the associated language of fenced code exist in the page content]
 57  # - shortcodes.css        = [List of CSS files to includes when the associated shortcode exist in the page content]
 58  # - shortcodes.js         = [List of javascript files to includes when the associated shortcode exist in the page content]
 59  # - shortcodes.jsModules  = [List of javascript module files to includes when the associated shortcode exist in the page content]
 60  #
 61  [params.includes]
 62    css = [
 63      "css/file1.css",
 64      "css/fileX.css"
 65    ]
 66    js = [
 67      "js/file1.js",
 68      "js/fileX.js"
 69    ]
 70    jsModules = [
 71      "js/modules/file1.js",
 72      "js/modules/fileX.js"
 73    ]
 74  [params.includes.fencedcodes.css]
 75    fencedcode1 = [
 76        "css/fencedcodes/fencedcode1.css"
 77      ]
 78    fencedcodeX = [
 79        "css/fencedcodes/fencedcodeX.css"
 80      ]
 81  [params.includes.fencedcodes.js]
 82    fencedcode1 = [
 83        "js/fencedcodes/fencedcode1.js"
 84      ]
 85    fencedcodeX = [
 86        "js/fencedcodes/fencedcodeX.js"
 87      ]
 88  [params.includes.fencedcodes.jsModules]
 89    fencedcode1 = [
 90        "js/fencedcodes/modules/fencedcode1.js"
 91      ]
 92    fencedcodeX = [
 93        "js/fencedcodes/modules/fencedcodeX.js"
 94      ]
 95  [params.includes.shortcodes.css]
 96    shortcode1 = [
 97        "css/shortcodes/shortcode1.css"
 98      ]
 99    shortcodeX = [
100        "css/shortcodes/shortcodeX.css"
101      ]
102  [params.includes.shortcodes.js]
103    shortcode1 = [
104        "js/shortcodes/shortcode1.js"
105      ]
106    shortcodeX = [
107        "js/shortcodes/shortcodeX.js"
108      ]
109  [params.includes.shortcodes.jsModules]
110    shortcode1 = [
111        "js/shortcodes/modules/shortcode1.js"
112      ]
113    shortcodeX = [
114        "js/shortcodes/modules/shortcodeX.js"
115      ]