From 05cbb49e9cb50086c4cb6fe20ffc40b8f10cb263 Mon Sep 17 00:00:00 2001 From: vimux Date: Fri, 30 Aug 2019 15:25:10 -0400 Subject: [PATCH] Add customJS --- README.md | 22 ++++++++++++++++++++++ layouts/_default/baseof.html | 3 +++ 2 files changed, 25 insertions(+) diff --git a/README.md b/README.md index 8b33135..488ded1 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ - [Configuration options](#configuration-options) - [Columns](#columns) - [Custom CSS](#custom-css) + - [Custom JS](#custom-js) - [Post Meta](#post-meta) - [Related Content](#related-content) - [Share Buttons](#share-buttons) @@ -140,6 +141,7 @@ googleAnalytics = "" # Enable Google Analytics by entering your tracking id dateFormat = "January 02, 2006" # Change the format of dates colorTheme = "" # dark-green, dark-blue, dark-red, dark-violet customCSS = ["css/custom.css"] # Include custom CSS files + customJS = ["js/custom.js"] # Include custom JS files mainMenuAlignment = "right" # Align main menu (desktop version) to the right side authorbox = true # Show authorbox at bottom of single pages if true toc = true # Enable Table of Contents for all site pages @@ -265,6 +267,26 @@ your Hugo site: All custom CSS files will be added in the `head` section of a `baseof.html` right after the built-in CSS file. +#### Custom JS + +You can add custom JavaScript files by assigning an array of references in site config file (`config.toml` by default) +like following: + +```toml +[Params] + customJS = ["js/custom.js"] +``` + +And of course, just like with custom CSS, you can reference as many JS files as you want. Their paths need to be +relative to the `static` folder of your Hugo site: + +```toml +[Params] + customJS = ["js/custom.js", "js/another.js"] +``` + +All custom JS files will be added before closing body tag of a `baseof.html` file. + #### Post Meta You may activate post meta fields with `.Site.Params.post_meta` parameter. diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 07ffe01..e38640b 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -50,5 +50,8 @@ {{- end }} {{- partial "mathjax.html" . -}} +{{- range .Site.Params.customJS }} + +{{- end }} \ No newline at end of file