
* Add support for custom footer * amend how the custom footer section is displayed * Add missing class * add missing class * Remove context variable and flag in hugo.yaml * update hugo_stats * Only show footer section for copyright and PoweredBy if they are enabled * Add missing compiled css * Added necessary variables for correct styling of the custom footer in some cases * make padding consistent for copyright section and custom footer * chore: update css * chore: clean up css * docs: update customization instructions * fix: footer padding --------- Co-authored-by: Xin <xin@imfing.com>
5.6 KiB
title | linkTitle |
---|---|
Customizing Hextra | Customization |
Hextra offers some default customization options in the hugo.yaml
config file to configure the theme.
This page describes the available options and how to customize the theme further.
Custom CSS
To add custom CSS, we need to create a file assets/css/custom.css
in our site. Hextra will automatically load this file.
Font Family
The font family of the content can be customized using:
.content {
font-family: "Times New Roman", Times, serif;
}
Inline Code Element
The color of text mixed with other text
can customized with:
.content code:not(.code-block code) {
color: #c97c2e;
}
Primary Color
The primary color of the theme can be customized by setting the --primary-hue
, --primary-saturation
and --primary-lightness
variables:
:root {
--primary-hue: 100deg;
--primary-saturation: 90%;
--primary-lightness: 50%;
}
Further Theme Customization
The theme can be further customized by overriding the default styles via the exposed css classes. An example for customizing the footer element:
.hextra-footer {
/* Styles will be applied to the footer element */
}
.hextra-footer:is(html[class~="dark"] *) {
/* Styles will be applied to the footer element in dark mode */
}
The following classes can be used to customize various parts of the theme.
General
hextra-scrollbar
- The scrollbar elementcontent
- Page content container
Shortcodes
Badge
hextra-badge
- The badge element
Card
hextra-card
- The card elementhextra-card-image
- The card image elementhextra-card-icon
- The card icon elementhextra-card-subtitle
- The card subtitle element
Cards
hextra-cards
- The cards grid container
Jupyter Notebook
hextra-jupyter-code-cell
- The Jupyter code cell containerhextra-jupyter-code-cell-outputs-container
- The Jupyter code cell outputs containerhextra-jupyter-code-cell-outputs
- The Jupyter code cell output div element
hextra-pdf
- The PDF container element
Steps
steps
- The steps container
Tabs
hextra-tabs-panel
- The tabs panel containerhextra-tabs-toggle
- The tabs toggle button
Filetree
hextra-filetree
- The filetree container
Folder
hextra-filetree-folder
- The filetree folder container
Navbar
nav-container
- The navbar containernav-container-blur
- The navbar container in blur elementhamburger-menu
- The hamburger menu button
Footer
hextra-footer
- The footer elementhextra-custom-footer
- The custom footer section container
Search
search-wrapper
- The search wrapper containersearch-input
- The search input elementsearch-results
- The search results list container
Table of Contents
hextra-toc
- The table of contents container
Sidebar
mobile-menu-overlay
- The overlay element for the mobile menusidebar-container
- The sidebar containersidebar-active-item
- The active item in the sidebar
Language Switcher
language-switcher
- The language switcher buttonlanguage-options
- The language options container
Theme Toggle
theme-toggle
- The theme toggle button
Cody Copy Button
hextra-code-copy-btn-container
- The code copy button containerhextra-code-copy-btn
- The code copy button
Code Block
hextra-code-block
- The code block container
Feature Card
hextra-feature-card
- The feature card link element
Feature Grid
hextra-feature-grid
- The feature grid container
Breadcrumbs
No specific class is available for breadcrumbs.
Syntax Highlighting
List of available syntax highlighting themes are available at Chroma Styles Gallery. The stylesheet can be generated using the command:
hugo gen chromastyles --style=github
To override the default syntax highlighting theme, we can add the generated styles to the custom CSS file.
Custom Scripts
You may add custom scripts to the end of the head for every page by adding the following file:
layouts/partials/custom/head-end.html
Custom Footer Section
You can add a custom section the footer between the language/theme buttons and the "Copyright"/"Powered By" section by creating a file layouts/partials/custom/footer.html
in your site.
<!-- Your footer element here -->
Available variables in the footer section are:
.switchesVisible
:true
if the language/theme button(s) are visible above the footer along with a horizontal separator..copyrightVisible
:true
if the "Copyright" and "Powered By" text are visible at the bottom of the footer.
Note: The custom footer inherits the default footer background color text color and the width
setting in hugo.yaml#footer
section.
Custom Layouts
The layouts of the theme can be overridden by creating a file with the same name in the layouts
directory of your site.
For example, to override the single.html
layout for docs, create a file layouts/docs/single.html
in your site.
For further information, refer to the Hugo Templates.
Further Customization
Didn't find what you were looking for? Feel free to open a discussion or make a contribution to the theme!