### Hugo Content Organization Structure Example Source: https://context7.com/jakob-r/coursetheme/llms.txt This example demonstrates the recommended directory structure for organizing course content within a Hugo project using the CourseTheme. It highlights the use of index files (_index.md) and numbered prefixes for explicit ordering of lectures and resources. ```bash # Directory structure example content/ ├── _index.md # Course homepage ├── lectures/ │ ├── _index.md # Lectures overview │ ├── 01-introduction/ │ │ ├── _index.md │ │ ├── slides.pdf │ │ └── exercises.pdf │ ├── 02-regression/ │ │ ├── _index.md │ │ └── slides.pdf │ └── 03-classification/ │ ├── _index.md │ └── slides.pdf └── resources/ ├── _index.md └── cheatsheet.pdf # Files are ordered alphabetically by path # Use numbered prefixes (01-, 02-) for explicit ordering ``` -------------------------------- ### Basic Theme Configuration TOML Source: https://context7.com/jakob-r/coursetheme/llms.txt Basic theme setup for CourseTheme requires minimal configuration within the Hugo site's config.toml file. This snippet indicates where theme configuration should be placed. ```toml # Basic theme setup requires minimal configuration in your Hugo site's config file. ``` -------------------------------- ### Hugo Configuration with config.toml for CourseTheme Source: https://context7.com/jakob-r/coursetheme/llms.txt This snippet shows the basic configuration for the CourseTheme in a Hugo project's config.toml file. It enables features like MathJax, custom video URLs, favicons, and logos, and sets up the main navigation menu. ```toml theme = "CourseTheme" title = "Machine Learning Course" [params] # Enable MathJax globally mathjax = true # Configure video embedding (YouTube by default) video_base_url = "https://www.youtube.com/embed/" # Optional: Enable favicon support use_favicon = true # Optional: Add course logo logo = "images/course-logo.png" # Navigation menu [[menu.main]] name = "Home" url = "/" weight = 1 [[menu.main]] name = "Lectures" url = "/lectures/" weight = 2 [[menu.main]] name = "Resources" url = "/resources/" weight = 3 ``` -------------------------------- ### Control Content Display in Index Pages Source: https://context7.com/jakob-r/coursetheme/llms.txt Allows control over how chapter overviews are displayed on index pages using the 'show_in_index' parameter. Options include 'summary', 'content', or 'none' to display summaries, full content, or just titles respectively. ```markdown --- title: "Course Module 1" show_in_index: "summary" --- # Introduction to Data Science This module covers fundamental concepts in data science. ``` -------------------------------- ### Link to File in Same Directory Shortcode Source: https://github.com/jakob-r/coursetheme/blob/main/README.md Use this shortcode to create links to files (like PDFs) that are in the same directory as the markdown file. Directly linking to files using markdown or HTML can break in index pages if relative paths like '../file.pdf' are used. ```go {{< fileurl file="cheatsheet_notation.pdf" >}} ``` -------------------------------- ### Content Display Options in Index Source: https://github.com/jakob-r/coursetheme/blob/main/README.md In `_index.md` files, you can control how content is displayed on index pages using the `show_in_index` parameter. Options include 'content', 'summary', or 'none'. ```markdown --- show_in_index: summary --- ``` -------------------------------- ### Create Interactive Quizzes with Quizdown Shortcode Source: https://context7.com/jakob-r/coursetheme/llms.txt Enables the creation of interactive, self-grading quizzes using Quizdown markdown syntax within Hugo. Supports multiple question types, mathematical notation, and code syntax highlighting. ```markdown --- title: "Week 1 Quiz" quizdown: true mathjax: false --- # Knowledge Check {{< quizdown >}} --- primary_color: steelblue --- # What is the capital of France? > This is a simple single-choice question - [ ] London - [x] Paris - [ ] Berlin - [ ] Madrid # Which are programming languages? > Multiple correct answers allowed - [x] Python - [x] JavaScript - [ ] HTML - [x] Rust # Calculate: $2^3 + 5$ What is the result? - [ ] 10 - [ ] 11 - [x] 13 - [ ] 15 {{< /quizdown >}} ``` -------------------------------- ### Enable MathJax for Mathematical Notation Source: https://context7.com/jakob-r/coursetheme/llms.txt Activates MathJax support to render LaTeX-style mathematical equations and formulas within course content. This is essential for technical and scientific subjects requiring precise notation. ```markdown --- title: "Linear Regression" mathjax: true --- # Mathematical Foundations The linear regression model is defined as: $$y = \beta_0 + \beta_1 x + \epsilon$$ Where $\beta_0$ is the intercept and $\beta_1$ is the slope coefficient. Inline math works too: The mean squared error is calculated as $MSE = \frac{1}{n}\sum_{i=1}^n(y_i - \hat{y}_i)^2$ Display equations: $$ \hat{\beta} = (X^TX)^{-1}X^Ty $$ ``` -------------------------------- ### Embed YouTube Video with Shortcode Source: https://context7.com/jakob-r/coursetheme/llms.txt Embeds YouTube videos using a shortcode in Markdown files. It creates a responsive iframe for video playback. The video source is determined by the 'id' parameter and potentially configured in config.toml. ```markdown --- title: "Introduction to Machine Learning" --- # Lecture 1: Overview Watch the introduction video below: {{< video id="Syrzezpj2FY" >}} The video will be embedded from the platform specified in your config.toml file. ``` -------------------------------- ### MathJax Enablement in Hugo Source: https://github.com/jakob-r/coursetheme/blob/main/README.md MathJax can be enabled globally in `config.toml`, per-page via frontmatter (`mathjax: true`), or for index pages by adding it to `_index.md`. Special handling is required for quizdown, where `mathjax: false` in YAML is necessary if MathJax is not desired in quizzes. ```toml # config.toml mathjax: true ``` ```markdown --- mathjax: true --- ``` ```markdown --- quizdown: true mathjax: false --- ``` -------------------------------- ### Generate Absolute File URLs with fileurl Shortcode Source: https://context7.com/jakob-r/coursetheme/llms.txt Generates correct absolute URLs for downloadable files, ensuring links remain functional across different site structures. This prevents broken links when navigating hierarchical content. ```markdown --- title: "Course Materials" --- Download the resources: - [Notation Cheatsheet]({{< fileurl file="cheatsheet_notation.pdf" >}}) - [Exercise Solutions]({{< fileurl file="solutions.pdf" >}}) - [R Code Examples]({{< fileurl file="examples.R" >}}) This ensures links work correctly whether viewed from /course/chapter1/ or /course/ ``` -------------------------------- ### Quizdown Integration Source: https://github.com/jakob-r/coursetheme/blob/main/README.md Enables quiz functionality using the hugo-quiz plugin. Set `quizdown: true` in the YAML frontmatter to activate quizzes. Quizzes inherently support MathJax rendering without requiring explicit MathJax enablement. ```markdown --- quizdown: true --- ``` -------------------------------- ### Section Navigation HTML Structure Source: https://context7.com/jakob-r/coursetheme/llms.txt HTML structure for automatic navigation buttons that appear at the bottom of single pages, facilitating sequential movement through course content. Navigation links are generated if 'NextInSection' or 'PrevInSection' exist. ```html
``` -------------------------------- ### Process PDF File Path with Go Templates Source: https://github.com/jakob-r/coursetheme/blob/main/layouts/shortcodes/pdfjs.html This Go template code processes a PDF file path to generate a unique identifier and an absolute URL for the PDF. It removes specific characters from the filename to create an ID and constructs a URL relative to the current page's directory, then makes it absolute. This is used to set up the PDF viewer. ```go-template {{ $pdf_file := .Get "file" }} {{ $pdf_id := replaceRE "\[.-\]" "_" $pdf_file }} {{ $pdf_url := path.Join .Page.Dir $pdf_file }} {{ $pdf_url := $pdf_url | absURL }} ``` -------------------------------- ### Embed PDF Files with PDF.js Viewer Shortcode Source: https://context7.com/jakob-r/coursetheme/llms.txt Embeds PDF documents using the pdfjs shortcode, enabling an interactive viewer with navigation controls directly within the webpage. The 'hidePaginator' option can be used to customize the viewer's appearance. ```markdown --- title: "Regression Analysis" --- # Lecture Slides {{< pdfjs file="slides-regression-losses.pdf" >}} {{< pdfjs file="handout.pdf" hidePaginator="true" >}} ``` -------------------------------- ### Embed PDF using pdfjs Shortcode Source: https://github.com/jakob-r/coursetheme/blob/main/README.md This shortcode allows embedding PDF files directly into your markdown content. The PDF file must be located in the same directory as the markdown file. It utilizes the hugo-embed-pdf-shortcode plugin. ```go {{< pdfjs file="slides-regression-losses.pdf" >}} ``` -------------------------------- ### Embed Lecture Video Shortcode Source: https://github.com/jakob-r/coursetheme/blob/main/README.md Embeds lecture videos, primarily from YouTube, using a provided video ID. The video ID is extracted from the YouTube URL. You can customize the base URL for other platforms or use a custom shortcode. ```go {{< video id = "Syrzezpj2FY" >}} ``` -------------------------------- ### Render PDF with PDF.js in JavaScript Source: https://github.com/jakob-r/coursetheme/blob/main/layouts/shortcodes/pdfjs.html This JavaScript code snippet utilizes the PDF.js library to load and display a PDF document on an HTML canvas. It includes functions for rendering pages, navigating between them, and handling the PDF loading process. The worker script and library are fetched from a CDN. Dependencies include the PDF.js library and an HTML canvas element with a specific ID. ```javascript window.addEventListener("load",function(){ // If absolute URL from the remote server is provided, configure the CORS // header on that server. var url = '{{ $pdf_url }}'; var hidePaginator = "{{ .Get "hidePaginator" }}"; // Loaded via