hugo-theme-relearn/exampleSite/content/basics/customization/_index.en.md

189 lines
7.9 KiB
Markdown
Raw Normal View History

+++
title = "Customization"
weight = 25
+++
2017-09-04 17:14:13 +00:00
The Relearn theme has been built to be as configurable as possible by defining multiple [partials](https://gohugo.io/templates/partials/)
2017-09-04 17:14:13 +00:00
In `themes/hugo-theme-relearn/layouts/partials/`, you will find all the partials defined for this theme. If you need to overwrite something, don't change the code directly. Instead [follow this page](https://gohugo.io/themes/customizing/). You'd create a new partial in the `layouts/partials` folder of your local project. This partial will have the priority.
2017-09-04 17:14:13 +00:00
This theme defines the following partials :
2022-02-14 20:44:01 +00:00
- `content.html`: the content page itself. This can be overridden if you wan't to display page's meta data above or below the content.
- `header.html`: the header of the content page (contains the breadcrumbs). _Not meant to be overwritten_
- `custom-header.html`: custom headers in page. Meant to be overwritten when adding CSS imports. Don't forget to include `style` HTML tag directive in your file
- `footer.html`: the footer of the content page (contains the arrows). _Not meant to be overwritten_
- `custom-footer.html`: custom footer in page. Meant to be overwritten when adding Javacript. Don't forget to include `javascript` HTML tag directive in your file
- `favicon.html`: the favicon
- `logo.html`: the logo, on top left hand corner
- `meta.html`: HTML meta tags, if you want to change default behavior
- `menu.html`: left menu. _Not meant to be overwritten_
- `menu-pre.html`: side-wide configuration to prepend to menu items. If you override this, it is your responsiblity to take the page's `pre` setting into account.
- `menu-post.html`: side-wide configuration to append to menu items. If you override this, it is your responsiblity to take the page's `post` setting into account.
- `menu-footer.html`: footer of the the left menu
- `search.html`: search box. _Not meant to be overwritten_
- `toc.html`: table of contents
2017-09-04 17:14:13 +00:00
## Change the logo
Create a new file in `layouts/partials/` named `logo.html`. Then write any HTML you want.
You could use an `img` HTML tag and reference an image created under the *static* folder, or you could paste a SVG definition!
2017-09-04 17:14:13 +00:00
{{% notice note %}}
The size of the logo will adapt automatically
{{% /notice %}}
## Change the favicon
2021-10-30 20:00:46 +00:00
If your favicon is a SVG, PNG or ICO, just drop off your image in your local `static/images/` folder and name it `favicon.svg`, `favicon.png` or `favicon.ico` respectivly.
If no favicon file is found, the theme will lookup the alternative filename `logo` in the same location and will repeat the search for the list of supported file types.
2017-09-04 17:14:13 +00:00
If you need to change this default behavior, create a new file in `layouts/partials/` named `favicon.html`. Then write something like this:
```html
2021-10-30 20:00:46 +00:00
<link rel="icon" href="/images/favicon.bmp" type="image/bmp" />
2017-09-04 17:14:13 +00:00
```
## Change default colors {#theme-variant}
The Relearn theme let you choose between some predefined color scheme variants, but feel free to add one yourself!
2021-07-01 14:25:08 +00:00
### Standard variant
```toml
[params]
2022-02-14 20:44:01 +00:00
# Change default color scheme with a variant one.
themeVariant = "" # or themeVariant = "relearn" or themeVariant = "relearn-light"
2021-07-01 14:25:08 +00:00
```
2022-02-14 20:44:01 +00:00
![Standard variant](images/standard-variant.png?width=60pc)
### Standard dark variant
```toml
[params]
# Change default color scheme with a variant one.
themeVariant = "relearn-dark"
```
![Dark variant](images/standard-dark-variant.png?width=60pc)
### Learn variant
```toml
[params]
# Change default color scheme with a variant one.
themeVariant = "learn"
```
![Learn variant](images/learn-variant.png?width=60pc)
2017-09-04 17:14:13 +00:00
### Red variant
```toml
[params]
2022-02-14 20:44:01 +00:00
# Change default color scheme with a variant one.
2017-09-04 17:14:13 +00:00
themeVariant = "red"
```
![Red variant](images/red-variant.png?width=60pc)
2017-09-04 17:14:13 +00:00
### Blue variant
```toml
[params]
2022-02-14 20:44:01 +00:00
# Change default color scheme with a variant one.
2017-09-04 17:14:13 +00:00
themeVariant = "blue"
```
![Blue variant](images/blue-variant.png?width=60pc)
2017-09-04 17:14:13 +00:00
### Green variant
```toml
[params]
2022-02-14 20:44:01 +00:00
# Change default color scheme with a variant one.
2017-09-04 17:14:13 +00:00
themeVariant = "green"
```
![Green variant](images/green-variant.png?width=60pc)
2017-09-04 17:14:13 +00:00
2021-09-07 19:32:21 +00:00
### 'Mine variant
2017-09-04 17:14:13 +00:00
First, create a new CSS file in your local `static/css` folder prefixed by `theme` (e.g. with _mine_ theme `static/css/theme-mine.css`). Copy the following content and modify colors in CSS variables.
```css
:root {
2022-02-10 23:59:40 +00:00
--MAIN-TEXT-color: #101010; /* Color of text by default */
--MAIN-TITLES-TEXT-color: #444753; /* Color of titles h2-h3-h4-h5-h6 */
--MAIN-LINK-color: #486ac9; /* Color of links */
--MAIN-LINK-HOVER-color: #134fbf; /* Color of hovered links */
--MAIN-ANCHOR-color: #486ac9; /* color of anchors on titles */
--MAIN-BG-color: #ffffff; /* color of text by default */
/* adjusted to relearn-light chroma style */
--CODE-BLOCK-color: #000000; /* fallback color for block code text */
--CODE-BLOCK-BG-color: #f8f8f8; /* fallback color for block code background */
--CODE-BLOCK-BORDER-color: #d8d8d8; /* color of block code border */
--CODE-INLINE-color: #5e5e5e; /* color for inline code text */
--CODE-INLINE-BG-color: #fffae9; /* color for inline code background */
--CODE-INLINE-BORDER-color: #f8e8c8; /* color of inline code border */
--MENU-HOME-LINK-color: #323232; /* Color of the home button text */
2022-02-10 23:59:40 +00:00
--MENU-HOME-LINK-HOVER-color: #808080; /* Color of the hovered home button text */
2022-02-10 23:59:40 +00:00
--MENU-HEADER-BG-color: #7dc903; /* Background color of menu header */
--MENU-HEADER-BORDER-color: #7dc903; /*Color of menu header border */
2017-09-04 17:14:13 +00:00
2022-02-10 23:59:40 +00:00
--MENU-SEARCH-color: #efefef; /* Color of search field text */
--MENU-SEARCH-BG-color: #3d414d; /* Search field background color (by default borders + icons) */
--MENU-SEARCH-BOX-color: #efefef; /* Override search field border color */
2017-09-04 17:14:13 +00:00
2022-02-10 23:59:40 +00:00
--MENU-SECTIONS-ACTIVE-BG-color: #202028; /* Background color of the active section and its children */
--MENU-SECTIONS-BG-color: #282830; /* Background color of other sections */
--MENU-SECTIONS-LINK-color: #bababa; /* Color of links in menu */
--MENU-SECTIONS-LINK-HOVER-color: #ffffff; /* Color of links in menu, when hovered */
--MENU-SECTION-ACTIVE-CATEGORY-color: #444444; /* Color of active category text */
--MENU-SECTION-ACTIVE-CATEGORY-BG-color: #ffffff; /* Color of background for the active category (only) */
2017-09-04 17:14:13 +00:00
2022-02-10 23:59:40 +00:00
--MENU-VISITED-color: #506397; /* Color of 'page visited' icons in menu */
--MENU-SECTION-HR-color: #606060; /* Color of <hr> separator in menu */
/* base styling for boxes */
--BOX-CAPTION-color: rgba( 255, 255, 255, 1 ); /* color of the title text */
--BOX-BG-color: rgba( 255, 255, 255, .833 ); /* color of the content background */
--BOX-TEXT-color: rgba( 16, 16, 16, 1 ); /* fixed color of the content text */
/* optional base colors for colored boxes as in attachments and notice shortcode */
--BOX-BLUE-color: rgba( 48, 117, 229, 1 );
--BOX-GREEN-color: rgba( 42, 178, 24, 1 );
--BOX-GREY-color: rgba( 128, 128, 128, 1 );
--BOX-ORANGE-color: rgba( 237, 153, 9, 1 );
--BOX-RED-color: rgba( 224, 62, 62, 1 );
2017-09-04 17:14:13 +00:00
}
```
Then, set the `themeVariant` value with the name of your custom theme file. That's it!
2017-09-04 17:14:13 +00:00
```toml
[params]
2022-02-14 20:44:01 +00:00
# Change default color scheme with a variant one.
2017-09-04 17:14:13 +00:00
themeVariant = "mine"
2018-01-22 21:39:54 +00:00
```
2022-02-13 00:53:23 +00:00
### Multiple variants
2022-02-14 20:44:01 +00:00
You can also set multiple variants. In this case, the first variant is the default choosen on first view and a theme switch will be shown in the menu footer.
2022-02-13 00:53:23 +00:00
```toml
[params]
2022-02-14 20:44:01 +00:00
# Change default color scheme with a variant one.
themeVariant = [ "relearn-light", "relearn-dark" ]
2022-02-13 00:53:23 +00:00
```
{{% notice tip %}}
If you want to switch the syntax highlightning theme together with your color variant, generate a syntax highlighting stylesheet and configure your installation [according to Hugo's documentation](https://gohugo.io/content-management/syntax-highlighting/), and `@import` this stylesheet in your color variant stylesheet. For an example, take a look into `theme-relearn-light.css` and `config.toml` of the exampleSite.
{{% /notice %}}