blob: 4979fb4b3535f0f9fe6f73917986fd41164823e1 (
plain)
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
|
+++
title = "Customize look and feel"
Weight=3
+++
You can change the style and behavior of the theme without touching its source code.
* inject your own html, css or js into the page
* overide existing css or js with your own files
{{%notice warning %}}
No needs to copy the entire theme to customize some parts
Bellow are solutions to avoid copying the entire theme into your own codebase.
{{%/notice%}}
## Add custom CSS and JS into the \<head\> part of each page :
Create a file as `layouts/partials/head.html`
```bash
content/
layouts/
└── partials/
└── head.html
```
write your own content like :
```html
<link rel="stylesheet" href="/css/custom.css">
<script src="/js/custom.js"></script>
```
Then override the style your want to change in `static/css/custom.css` (in this case, to avoid altering the casing of titles):
```css
h2 {
text-transform: none;
}
```
And execute some additional JavaScript from `static/js/custom.js` (note that jQuery is already loaded by the theme):
```javascript
function tweakPage() {
// make some changes here
}
$(tweakPage)
```
now feel free to add the JS, CSS code you want :)
## Add custom HTML before and after key elements of this theme
* @see [site placeholders]({{%relref "content-organisation/placeholders/_index.md"%}})
## Overide existing CSS or JS
Create the matching file in your static folder, hugo will use yours instead of the theme's one.
|