/
index.md
174 lines (129 loc) Β· 5.07 KB
/
index.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
---
title: Advanced Usage
date: 2024-04-06T12:59:28+08:00
type: posts
author:
name: Lruihao
link: https://lruihao.cn
description: Discover advanced usage of the Hugo - FixIt theme.
resources:
- name: featured-image
src: featured-image.png
categories:
- Documentation
collections:
- Documentation
tags:
- Advanced
- Customization
reward: true
toc:
auto: false
menu:
main:
title: Discover advanced usage of the Hugo - FixIt theme.
parent: documentation
weight: 4
params:
icon: fa-brands fa-readme
---
Discover advanced usage of the Hugo - **FixIt** theme.
<!--more-->
## Style Customization
{{< version 0.2.8 changed >}}
{{< admonition >}}
Hugo **extended** version is necessary for the style customization.
{{< /admonition >}}
**FixIt** theme has been built to be as configurable as possible by defining custom `.scss` style files.
The directory including the custom `.scss` style files is `assets/css` relative to **your project root directory**.
In `assets/css/_override.scss`, you can override the variables in `themes/FixIt/assets/css/_variables.scss` to customize the style.
Here is a example:
```scss
@import url('https://fonts.googleapis.com/css?family=Fira+Mono:400,700&display=swap&subset=latin-ext');
$code-font-family: Fira Mono, Source Code Pro, Menlo, Consolas, Monaco, monospace;
```
In `assets/css/_custom.scss`, you can add some css style code to customize the style.
### Page Style {#page-style}
{{< version 0.2.13 >}}
The FixIt theme provides a page width configuration option `pageStyle` and three values.
- **narrow** Keep `<v0.2.13` page/toc width ratio
- **normal** New default page/toc width ratio
- **wide** Larger page/toc width ratio
In addition, you can also customize the `pageStyle` value in `assets/css/_custom.scss`
For example: `pageStyle="custom"`
```scss
[data-page-style='custom'] {
@media only screen and (min-width: 1441px) {
%page-style {
width: 70%;
}
}
@media only screen and (min-width: 1440px) {
%page-style {
width: 60%;
}
}
@media only screen and (min-width: 1200px) {
%page-style {
width: 56%;
}
}
}
```
### Print Style {#print-style}
{{< version 0.2.13 >}}
There are three css common class for print view in FixIt Theme.
- `page-break-before` Insert page break before element
- `page-break-after` Insert page break after element
- `print-d-none` Hide elements in print view
Here is a simple exmple:
```html
<div class="page-break-before"></div>
<div class="page-break-after"></div>
<div class="print-d-none">
Something you want to hide in the print view is written here.
</div>
```
If you set `goldmark.parser.attribute.block` to `true`, you can also use:
```markdown
{.page-break-before}
{.page-break-after}
Something you want to hide in the print view is written here.
{.print-d-none}
```
## Script Customization
{{< version 0.2.16 >}}
The directory including the custom script file named `custom.js` is `assets/js` relative to **your project root directory**.
If the script file `assets/js/custom.js` exists, it will be executed at the end of each post and page.
## Templates Customization
Hugo allows you to modify the theme by overriding the theme templates, for example: you can create `layouts/404.html` file to override `themes/FixIt/layouts/404.html`, so as to meet the needs of custom 404 page template of FixIt theme.
However, for most of the templates, FixIt theme generally doesn't recommend you do this, as it may make theme upgrades difficult in the future.
In order to avoid upgrade conflicts, based on this feature, the FixIt theme opens several empty templates in commonly used locations for user customization, see `params.customFilePath` parameter in [theme configuration][theme-config].
For example, the FixIt theme documentation site customizes the profile section of the home page by creating `layouts/partials/custom/profile.html`.
First enable custom file path parameter:
```toml
[params.customFilePath]
profile = "custom/profile.html"
```
then, customize the template:
```go-html-template
<div class="profile-custom">
{{- if .Site.BuildDrafts -}}
<a href="https://fixit.lruihao.cn" target="_blank" rel="external" title="Go to Production Environment">
<img src="https://img.shields.io/github/deployments/hugo-fixit/docs/Production?style=flat&label=Production&logo=vercel" alt="Production environment">
</a>
{{- else -}}
<a href="https://pre.fixit.lruihao.cn" target="_blank" rel="external" title="Go to Preview Environment">
<img src="https://img.shields.io/github/deployments/hugo-fixit/docs/Preview?style=flat&label=Preview&logo=vercel" alt="Preview environment">
</a>
{{- end -}}
<a href="https://demo.fixit.lruihao.cn" target="_blank" rel="external" title="FixIt Demo">
<img src="https://img.shields.io/badge/Demo-orange" alt="FixIt Demo">
</a>
</div>
```
## PWA Support
This part is shown in the [pwa support page][pwa-support].
<!-- link reference definition -->
[theme-config]: {{< relref path="/documentation/getting-started/configuration#theme-configuration" >}}
[pwa-support]: {{< relref path="/guides/pwa-support" >}}