2023-08-17 23:54:17 +01:00
---
title: Customizing Hextra
linkTitle: Customization
---
2023-08-21 01:00:52 +01:00
2023-08-21 23:41:37 +01:00
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.
<!-- more -->
2023-08-21 01:00:52 +01:00
## Custom CSS
2023-09-13 14:34:46 -07:00
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:
2023-08-21 23:41:37 +01:00
```css {filename="assets/css/custom.css"}
.content {
font-family: "Times New Roman", Times, serif;
}
```
2023-09-13 14:34:46 -07:00
### Inline Code Element
The color of text mixed with `other text` can customized with:
```css {filename="assets/css/custom.css"}
.content code:not(.code-block code) {
color: #c97c2e ;
}
```
2023-08-21 23:41:37 +01:00
### Primary Color
2024-10-14 23:11:37 +01:00
The primary color of the theme can be customized by setting the `--primary-hue` , `--primary-saturation` and `--primary-lightness` variables:
2023-08-21 23:41:37 +01:00
```css {filename="assets/css/custom.css"}
:root {
--primary-hue: 100deg;
2023-10-04 20:41:59 +01:00
--primary-saturation: 90%;
2024-10-14 23:11:37 +01:00
--primary-lightness: 50%;
2023-08-21 23:41:37 +01:00
}
```
2024-12-18 22:48:42 +00:00
### 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:
```css {filename="assets/css/custom.css"}
.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 element
- `content` - Page content container
#### Shortcodes
##### Badge
- `hextra-badge` - The badge element
##### Card
- `hextra-card` - The card element
- `hextra-card-image` - The card image element
- `hextra-card-icon` - The card icon element
- `hextra-card-subtitle` - The card subtitle element
##### Cards
- `hextra-cards` - The cards grid container
##### Jupyter Notebook
- `hextra-jupyter-code-cell` - The Jupyter code cell container
- `hextra-jupyter-code-cell-outputs-container` - The Jupyter code cell outputs container
- `hextra-jupyter-code-cell-outputs` - The Jupyter code cell output div element
##### PDF
- `hextra-pdf` - The PDF container element
##### Steps
- `steps` - The steps container
##### Tabs
- `hextra-tabs-panel` - The tabs panel container
- `hextra-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 container
- `nav-container-blur` - The navbar container in blur element
- `hamburger-menu` - The hamburger menu button
#### Footer
- `hextra-footer` - The footer element
2024-12-25 21:25:47 +00:00
- `hextra-custom-footer` - The custom footer section container
2024-12-18 22:48:42 +00:00
#### Search
- `search-wrapper` - The search wrapper container
- `search-input` - The search input element
- `search-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 menu
- `sidebar-container` - The sidebar container
- `sidebar-active-item` - The active item in the sidebar
#### Language Switcher
- `language-switcher` - The language switcher button
- `language-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 container
- `hextra-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.
2023-08-21 23:41:37 +01:00
### Syntax Highlighting
List of available syntax highlighting themes are available at [Chroma Styles Gallery ](https://xyproto.github.io/splash/docs/all.html ). The stylesheet can be generated using the command:
2023-11-11 20:14:39 -05:00
```shell
hugo gen chromastyles --style=github
2023-08-21 23:41:37 +01:00
```
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
```
2024-12-26 23:50:11 +00:00
## Custom Extra Section in Footer
2024-12-25 21:25:47 +00:00
2024-12-26 23:50:11 +00:00
You can add extra section in the footer by creating a file `layouts/partials/custom/footer.html` in your site.
2024-12-25 21:25:47 +00:00
```html {filename="layouts/partials/custom/footer.html"}
<!-- Your footer element here -->
```
2024-12-26 23:50:11 +00:00
The added section will be added before the copyright section in the footer.
You can use [HTML ](https://developer.mozilla.org/en-US/docs/Web/HTML ) and [Hugo template syntax ](https://gohugo.io/templates/ ) to add your own content.
2024-12-25 21:25:47 +00:00
2024-12-26 23:50:11 +00:00
Hugo variables available in the footer section are: `.switchesVisible` and `.copyrightVisible` .
2024-12-25 21:25:47 +00:00
2023-08-21 23:41:37 +01:00
## 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.
2024-12-26 23:50:11 +00:00
For further information, refer to the [Hugo Templates][hugo-template-docs].
2023-08-21 23:41:37 +01:00
## Further Customization
2023-11-11 20:14:39 -05:00
Didn't find what you were looking for? Feel free to [open a discussion ](https://github.com/imfing/hextra/discussions ) or make a contribution to the theme!
2024-12-26 23:50:11 +00:00
[hugo-template-docs]: https://gohugo.io/templates/