hugo-theme-ncsu #
Example / documentation page for the Bootstrap 5 version of the unofficial hugo-theme-ncsu
.
Config #
General config options for hugo are listed here: https://gohugo.io/getting-started/configuration/
|
|
baseURL
: Base URL for the site, (often?) set by deploy platform. Affects how relative links are handled (and might cause broken CSS / JS if not set correctly). Needs to be set to base URL of course website when manually deploying the html, e.g.,baseURL = "courseXX.example.org"
languageCode
: Displayed in the website header aslang
attribute, likely not very relevant except for search engines.title
: Default website title displayed in the tab and search engines if no specific page title is set.theme
: Name of theme to use from thethemes
folder (this theme).
Parameters #
|
|
Theme-specific #
Theme settings. Can be overwritten for individual pages in their front matter.
showToC = true
: Show (autogenerated) Table of Content (ToC) based on markdown headings on the rightshowSidebar = true
: Show sidebar on the left. Sidebar content generated from/layouts/partials/sidebar.html
.showWIP = true
: Show ‘work in progress’ message at top of every page. Content generated from/layouts/partials/wip.html
.showFooter = true
: Site footer with some lecture info. Content generated from/layouts/partials/footer.html
.
Show Sidebar #
Display left sidebar if showSidebar = true
.
Set in a /layouts/partials/sidebar.html
file.
Show Table of Contents #
Display right table of content if showToC = true
.
Auto-generated from markdown headings, included levels can be modified in hugo.toml
.
Show WIP #
Display following info box towards the top off every page if showWIP = true
:
Can be overwitten with a /layouts/partials/wip.html
file.
Show Footer #
Display footer at bottom of each page if showFooter = true
.
Generated from some of the course variables, can be overwritten woth a /layouts/partials/footer.html
file.
Course Variables #
Course-specific variables.
- Display in html file in the form of
{{ .Site.Params.cshort }}
- Display in markdown file with the param shortcode
{{< param "cshort" >}}
Menu #
Menu displayed on the top right of every page.
|
|
Bootstrap Shortcodes #
Shortcodes that wrap some Bootstrap elements and classes for easier use in Markdown files. Note that HTML code with Bootstrap classes is also valid Markdown and will render.
Alert #
Bootstrap alert text box with customizable markdown content. First parameter is passed as class (for setting color).
- Bootstrap documentation: https://getbootstrap.com/docs/5.3/components/alerts/
- Example parameters:
alert-primary
(red),alert-secondary
(grey),alert-success
(green), …
Usage:
|
|
Examples:
alert-primary
alert-success
alert-info
Badge #
Bootstrap badge span with customizable markdown content.
- Bootstrap documentation: https://getbootstrap.com/docs/5.3/components/badge/
- Example parameters:
alert-primary
(red),alert-secondary
(grey),alert-success
(green), …
|
|
Primary
Examples:
Primary Secondary Info Warning SuccessPill Badge #
With .rounded-pill
class.
|
|
Button #
Bootstrap button with customizable markdown content.
- Bootstrap documentation: https://getbootstrap.com/docs/5.3/components/buttons/
|
|
Examples:
Outline Buttons #
With .btn-outline-*
classes:
|
|
Examples:
Card #
Generic bootstrap card that displays content as body text. No additional parameters.
Usage:
|
|
Examples:
Also plays well with the columns short code:
Col & Row #
Bootstrap column & row class wrappers.
- Bootstrap documentation: https://getbootstrap.com/docs/5.3/layout/grid/
- Bootstrap grid works with 12 vertical, i.e., col-8 will leave 4 vertical slots for remaining columns.
|
|
Column 1 #
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Column 2 (Larger) #
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Columns #
columns
shortcode will be deprecated in the future in favor of the bootstrap-native row
and col
.Shortcode to generate two columns.
width
as optional parameter to set maximum width for each column in px (will wrap if wider).split
as optional parameter to set split ratio between columns (i.e.split = "2/1"
for 66% and 33%). Overwrites any width parameter.
The two columns are split by <--->
.
|
|
Also works for more than 2 columns:
With different split ratios:
|
|
Left Column #
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Right Column #
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Splits also work for multiple columns
|
|
Details #
Shortcode for the HTML “details” built-in to show/hide longer content adapted for Bootstrap 5. Takes up to 2 parameters and inner content:
- pos 0, “title”: Title shown for the summary
- pos 1, “open”: Whether the detail starts expanded
- inner: Text hidden / displayed by the summary
Usage:
|
|
|
|
Examples:
Title of the Detail
Detail that starts open
Table #
Wrapper shortcode to use bootstrap table classes for markdown tables. Pass classes as parameters, markdown table as inner content.
- Modified from: https://stackoverflow.com/questions/64609165/how-to-give-a-hugo-markdown-table-a-class-when-the-table-contains-shortcodes
Usage:
|
|
Example:
Format | In-person, recorded |
Credits | 3 |
Meeting Times | 6:00 am |
Meeting Location | Earth |
Instructor | Dr. Doe |
Custom Shortcodes #
Custom shortcodes for this theme (mostly focused around class schedules).
Assignment #
Assignment shortcode with multiple displays of assignment data from /data/assignments.toml
.
Real-world examples on the assignments page.
Example data entry:
|
|
Shortcode parameters:
- pos 0, “id”: Specific assignment selected by
id
field from/data/assignments.toml
. - pos 1, “type”: optional type to control what data is displayed (see examples below for all options).
Default #
Without any type just renders assignment title with link to assignment page
if provided:
|
|
badge #
type=badge
renders as badge with link to assignment url
if provided.
- Different badge color optionally set by a
color
variable in the data file. Color options follow the Bootstrap 5 badge format, e.g.,bg-primary
,bg-info
, etc. - Theme has custom additional badge classes for more colors;
bg-blue
,bg-purple
etc. - Color class can be combined with text classes for hard to read text colors, e.g.
color = "bg-warning text-dark"
|
|
date #
type=date
renders due date and time:
|
|
countdown #
type=countdown
renders a countdown for the time in the date
field.
Should be timezone aware using the moments.js
library (not extensively tested), assumes EST (America/NewYork
) time for the provided date
data:
|
|
Chart #
Wrapper shortcode to render a chart.js
chart directly in markdown.
Automatically includes the chart.js library.
Optional parameters:
- pos 0: width in percent
- pos 1: height in pixels
Usage:
|
|
Example:
Schedule #
Collection of 3 mostly independent shortcodes week
, happening
, and lecture
to render a schedule using Bootstrap 5 cards (see schedule for real-world examples).
- All 3 shortcodes can automatically compute and display dates if a
startDate = 2024-08-19
(first Monday of the semester) variable is set in the page frontmatter. Otherwise they will fall back to not showing specific dates. - Note that all schedule shortcodes need to be initiated with
{{% %}}
, not the usual{{< >}}
because the week shortcode needs to appear early in the rendering pipeline to show up in the ToC and the other shortcodes need to appear in the same context for shared variables.
A combined use of the three shortcodes in a schedule could look like this:
|
|
Week #
Displays a week heading (also shows up in ToC).
- Automatically counts up from Week 1. Manually set week with a
week = "XX"
shortcode parameter, will continue counting automatically from set value. - Optionally set a
title
variabel to show up in the week title and ToC. - Optionally with specific week dates (in grey) if
startDate
variable is set on page.
Usage:
|
|
Examples:
Week 1 #
Monday, 2024-08-19 - Friday, 2024-08-23
Week 2 - Example #
Monday, 2024-08-26 - Friday, 2024-08-30
Week 20 #
Monday, 2024-12-30 - Friday, 2025-01-03
Week 21 #
Monday, 2025-01-06 - Friday, 2025-01-10
Happening #
Generic happening schedule shortcode with a number of display options. Date is derived from the day
parameter and last week shortcode used.
Short code parameters:
- pos 0,
day
: Day of the happening (3 letter lower), e.g.,day = "mon"
,tue
, etc. - pos 1,
type
: optional type of the happening (different display, see below for examples) - pos 2,
time
: optional time argument, shown on the right side of the header if provided (useful for, e.g., exams) - Inner content rendered as markdown
Default #
No type, generic grey, single line happening
|
|
noclass #
type=noclass
, green background, single line, e.g. used for no class happening.
|
|
deadline #
type=deadline
, red outline, deadline events. Takes optional time parameter.
|
|
Mostly works well with the assignment
shortcode (minus the countdown type currently):
|
|
exam #
type=exam
, red background, multi-line exam event. Takes optional exam time.
|
|
Lecture #
The lecture shortcode renders lecture data from /data/lectures.toml
by provided id.
Example lecture entry with optional parameters commented out:
|
|
id
: ID to retrive this lecture by from the shortcode (e.g.{{% schedule/lecture "mon" "lec-intro" %}}
for the idlec-intro
).title
: Lecture titlelabel
: Optional label to directly reference lecture on page (link id) and displayed in header. ID is used if not set.description
: Optional description text displayed for the lecture. Supports markdown.short
: Optional text displayed before the lecture title (e.g., “Guest Lecture”). Defaults to “Lecture X” with automatically incrementing counter.time
: Optional parameter to overwrite the lecture time displayed in the header. Defaults to page variablelectureTime
or no display if the page variable is not set.slides
: Link to lecture slides.recording
: Link to lecture recording.
Optionally, discussion
, mentioned
, and additional
subtables can be provided to display additional resources (including some icons based on the type):
[intro.additional]
a1 = {authors="BD Payne, WK Edwards", title="A Brief Introduction to Usable Security", url="https://faculty.cc.gatech.edu/~keith/pubs/ieee-intro-usable-security.pdf", venue="IEEE Internet Computing", date="2008", type = "paper"}
[intro.mentioned]
m1 = {title="ACM SIGSOFT Empirical Standards for Software Engineering", url="https://www2.sigsoft.org/EmpiricalStandards/tools/", type="website"}
Automatic settings:
- Displays specific dates based on last week shortcode and passed weekday parameter, requires
startDate
to be set on the page. - Displays lecture times in the header if a page frontmatter variable is set:
lectureTime = "6:00pm-7:15pm"
- Automatically counts up lecture counter (“Lecture 1: …”), can be overwritten for each lecture in the toml, e.g.,
short = "Guest Lecture"
.
Short code parameters:
- pos 0,
day
: Day of the lecture (3 letter lower), e.g.,mon
,tue
, etc. - pos 1,
id
: ID of the lecture to display from the toml file, can be alphanumeric, e.g.,lec-intro
. - pos 2,
recorded
: optional, for pre-recorded lectures, replaces lecture time and adds warning that this lecture won’t be in person
Examples:
|
|
- 🗎 BD Payne, WK Edwards, A Brief Introduction to Usable Security, IEEE Internet Computing, 2008.
With recorded = true
set in shortcode:
|
|
- 🗎 BD Payne, WK Edwards, A Brief Introduction to Usable Security, IEEE Internet Computing, 2008.