Browse Source

Add support for custom CSS and JS assets

George Cushen 9 years ago
parent
commit
280d5ca1d4
3 changed files with 12 additions and 0 deletions
  1. 4 0
      exampleSite/config.toml
  2. 3 0
      layouts/partials/footer.html
  3. 5 0
      layouts/partials/header.html

+ 4 - 0
exampleSite/config.toml

@@ -26,6 +26,10 @@ googleAnalytics = ""
     #   Examples: "Mon, Jan 2, 2006" or "2006-01-02"
     date_format = "Mon, Jan 2, 2006"
 
+    # Link custom CSS and JS assets (relative to /static/css and /static/js respectively)
+    custom_css = []
+    custom_js  = []
+
     [[params.education]]
         course = "PhD in Artificial Intelligence"
         institution = "Stanford University"

+ 3 - 0
layouts/partials/footer.html

@@ -3,6 +3,9 @@
         <script src="{{ .Site.BaseURL }}js/jquery-1.12.3.min.js"></script>
         <script src="{{ .Site.BaseURL }}js/bootstrap.min.js"></script>
         <script src="{{ .Site.BaseURL }}js/hugo-academic.js"></script>
+        {{ range .Site.Params.custom_js }}
+        <link rel="stylesheet" href="{{ $.Site.BaseURL }}js/{{ . }}">
+        {{ end }}
 
         {{ with .Site.GoogleAnalytics }}
         <script>

+ 5 - 0
layouts/partials/header.html

@@ -15,6 +15,11 @@
     <link rel="stylesheet" href="{{ .Site.BaseURL }}css/font-awesome.min.css" />
     <link rel="stylesheet" href="{{ .Site.BaseURL }}css/academicons.min.css" />
     <link rel="stylesheet" href="{{ .Site.BaseURL }}css/hugo-academic.css" />
+    {{ range .Site.Params.custom_css }}
+    <link rel="stylesheet" href="{{ $.Site.BaseURL }}css/{{ . }}">
+    {{ end }}
+
+
     <link rel="shortcut icon" href="{{ .Site.BaseURL }}img/favicon.ico" type="image/x-icon" />
     <link rel="canonical" href="{{ .Permalink }}" />