Skip to content

Commit c59c919

Browse files
committed
Big documentation rewrite, move docs to example site
1 parent bcce6e2 commit c59c919

54 files changed

Lines changed: 1209 additions & 3152 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 9 additions & 293 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,6 @@
88

99
![Screenshot](https://raw.githubusercontent.com/alex-shpak/hugo-book/main/images/screenshot.png)
1010

11-
- [Features](#features)
12-
- [Requirements](#requirements)
13-
- [Installation](#installation)
14-
- [Menu](#menu)
15-
- [Blog](#blog)
16-
- [Configuration](#configuration)
17-
- [Shortcodes](#shortcodes)
18-
- [Versioning](#versioning)
19-
- [Contributing](#contributing)
20-
2111
## Features
2212

2313
- Clean simple design
@@ -31,303 +21,29 @@
3121
- Primary features work without JavaScript
3222
- Dark Mode
3323

34-
## Requirements
35-
36-
- Hugo 0.158 or higher
37-
- Hugo extended version, [Installation Instructions](https://gohugo.io/installation/)
38-
39-
## Installation
40-
41-
### Install as git submodule
42-
Navigate to your hugo project root and run:
43-
44-
```
45-
git submodule add https://github.com/alex-shpak/hugo-book themes/hugo-book
46-
```
47-
48-
Then run hugo (or set `theme = "hugo-book"`/`theme: hugo-book` in configuration file)
49-
50-
```
51-
hugo server --minify --theme hugo-book
52-
```
53-
54-
### Install as hugo module
55-
56-
You can also add this theme as a Hugo module instead of a git submodule.
57-
58-
Start with initializing hugo modules, if not done yet:
59-
```
60-
hugo mod init github.com/repo/path
61-
```
62-
63-
Navigate to your hugo project root and add [module] section to your `hugo.toml`:
64-
65-
```toml
66-
[module]
67-
[[module.imports]]
68-
path = 'github.com/alex-shpak/hugo-book'
69-
```
70-
71-
Then, to load/update the theme module and run hugo:
24+
## Quick Start
25+
Use the [starter repository](https://github.com/alex-shpak/hugo-book-starter):
7226

7327
```sh
74-
hugo mod get -u
28+
git clone https://github.com/alex-shpak/hugo-book-starter my-docs
29+
cd my-docs
30+
git submodule update --init --remote
7531
hugo server --minify
7632
```
7733

78-
### Creating site from scratch
79-
80-
Below is an example on how to create a new site from scratch:
81-
82-
```sh
83-
hugo new site mydocs; cd mydocs
84-
git init
85-
git submodule add https://github.com/alex-shpak/hugo-book themes/hugo-book
86-
cp -R themes/hugo-book/exampleSite/content.en/* ./content
87-
```
88-
89-
```sh
90-
hugo server --minify --theme hugo-book
91-
```
92-
93-
## Menu
94-
95-
By default, the theme will render pages from the `content/docs` section as a menu in a tree structure.
96-
You can set `title` and `weight` in the front matter of pages to adjust the order and titles in the menu, as well as other parameters to hide or alter urls in the menu. You can choose which folder to use for generating menu with `BookSection` configuration parameter.
97-
98-
## Blog
99-
100-
A simple blog is supported in the section `posts`.
101-
A blog is not the primary usecase of this theme, so it has only minimal features.
102-
103-
## Configuration
104-
105-
### Site Configuration
106-
107-
There are a few configuration options that you can add to your `hugo.toml` file.
108-
You can also see the `yaml` example [here](https://github.com/alex-shpak/hugo-book/blob/main/exampleSite/hugo.yaml).
109-
110-
```toml
111-
# (Optional) Set Google Analytics if you use it to track your website.
112-
# Always put it on the top of the configuration file, otherwise it won't work
113-
googleAnalytics = "UA-XXXXXXXXX-X"
114-
115-
# (Optional) If you provide a Disqus shortname, comments will be enabled on
116-
# all pages.
117-
disqusShortname = "my-site"
118-
119-
# (Optional) Set this to true if you use capital letters in file names
120-
disablePathToLower = true
121-
122-
# (Optional) Set this to true to enable 'Last Modified by' date and git author
123-
# information on 'doc' type pages.
124-
enableGitInfo = true
125-
126-
# (Optional) Theme is intended for documentation use, therefore it doesn't render taxonomy.
127-
# You can remove related files with config below
128-
disableKinds = ['taxonomy', 'taxonomyTerm']
129-
130-
# (Optional) Copyright information of the hugo book content
131-
copyright = '[© CC BY 4.0](https://creativecommons.org/licenses/by/4.0/legalcode)'
132-
133-
[params]
134-
# (Optional, default light) Sets color theme: light, dark or auto.
135-
# Theme 'auto' switches between dark and light modes based on browser/os preferences. With plugins/themes added there are more themes.
136-
BookTheme = 'light'
137-
138-
# (Optional, default true) Controls table of contents visibility on right side of pages.
139-
# Start and end levels can be controlled with markup.tableOfContents setting.
140-
# You can also specify this parameter per page in front matter.
141-
BookToC = true
142-
143-
# (Optional, default none) Set the path to a logo for the book. If the logo is
144-
# /static/logo.png then the path would be 'logo.png'
145-
BookLogo = 'logo.png'
146-
147-
# (Optional, default 'favicon.png') Set the path to a favicon for the site.
148-
# If the favicon is in /static/custom.svg, then the path would be 'custom.svg'.
149-
BookFavicon = 'favicon.png'
150-
151-
# (Optional, default docs) Specify section of content to render as menu
152-
# You can also set value to "*" to render all sections to menu
153-
BookSection = 'docs'
154-
155-
# (Optional, default none) Set template for commit link for the page. Requires enableGitInfo.
156-
# When set enabled 'Last Modified' and a link to the commit in the footer of the page.
157-
# Param is executed as template using .Site, .Page and .GitInfo as context.
158-
BookLastChangeLink = 'https://github.com/alex-shpak/hugo-book/commit/{{ .GitInfo.Hash }}'
159-
160-
# (Optional, default none) Set template for edit page link.
161-
# When set enabled 'Edit this page' link in the footer of the page.
162-
# Param is executed as template using .Site, .Page and .Path as context.
163-
BookEditLink = 'https://github.com/alex-shpak/hugo-book/edit/main/exampleSite/{{ .Path }}'
164-
165-
# (Optional, default 'January 2, 2006') Configure the date format used on the pages
166-
# - In git information
167-
# - In blog posts
168-
# https://gohugo.io/functions/time/format/
169-
BookDateFormat = 'January 2, 2006'
170-
171-
# (Optional, default true) Enables search function with flexsearch,
172-
# Index is built on fly, therefore it might slowdown your website.
173-
# Configuration for indexing can be adjusted in i18n folder per language.
174-
BookSearch = true
175-
176-
# (Optional, default true) Enables comments template on pages
177-
# By default partials/docs/comments.html includes Disqus template
178-
# See https://gohugo.io/content-management/comments/#configure-disqus
179-
# Can be overwritten by same param in page frontmatter
180-
BookComments = true
181-
182-
# /!\ This is an experimental feature, might be removed or changed at any time
183-
# (Optional, experimental, default false) Enables portable links and link checks in markdown pages.
184-
# Portable links meant to work with text editors and let you write markdown without {{< relref >}} shortcode
185-
# Theme will print warning if page referenced in markdown does not exists.
186-
BookPortableLinks = true
187-
188-
# /!\ This is an experimental feature, might be removed or changed at any time
189-
# (Optional, experimental, default false) Enables service worker that caches visited pages and resources for offline use.
190-
BookServiceWorker = true
191-
```
192-
193-
### Multi-Language Support
194-
195-
Theme supports Hugo's [multilingual mode](https://gohugo.io/content-management/multilingual/), just follow configuration guide there. You can also tweak search indexing configuration per language in `i18n` folder.
196-
197-
### Page Configuration
198-
199-
You can specify additional params in the front matter of individual pages:
200-
201-
```toml
202-
# Set type to 'docs' if you want to render page outside of configured section or if you render section other than 'docs'
203-
type = 'docs'
204-
205-
# Set page weight to re-arrange items in file-tree menu.
206-
weight = 10
207-
208-
# (Optional) Copyright information of the hugo page content
209-
# Can be used to override the site-wide copyright notice
210-
copyright = '[© CC BY 4.0](https://creativecommons.org/licenses/by/4.0/legalcode)'
211-
212-
# (Optional) Set to 'true' to mark page as flat section in file-tree menu.
213-
bookFlatSection = false
214-
215-
# (Optional) Set to hide nested sections or pages at that level. Works only with file-tree menu mode
216-
bookCollapseSection = true
217-
218-
# (Optional) Set true to hide page or section from side menu.
219-
bookHidden = false
220-
221-
# (Optional) Set 'false' to hide ToC from page
222-
bookToC = true
223-
224-
# (Optional) If you have enabled BookComments for the site, you can disable it for specific pages.
225-
bookComments = true
226-
227-
# (Optional) Set to 'true' to exclude page from search index.
228-
bookSearchExclude = false
229-
230-
# (Optional) Set explicit href attribute for this page in a menu.
231-
bookHref = ''
232-
233-
# /!\ This is an experimental feature, might be removed or changed at any time
234-
# (Optional) Set an icon for the menu entity of the page, icons are discovered from `assets/icons` folder.
235-
bookIcon = 'calendar'
236-
```
237-
238-
## Partials
239-
240-
There are layout partials available for you to easily override components of the theme in `layouts/partials/`.
241-
242-
In addition to this, there are several empty partials you can override to easily add/inject code.
243-
244-
| Empty Partial | Placement |
245-
| -------------------------------------------------- | ------------------------------------------- |
246-
| `layouts/partials/docs/inject/head.html` | Before closing `<head>` tag |
247-
| `layouts/partials/docs/inject/body.html` | Before closing `<body>` tag |
248-
| `layouts/partials/docs/inject/footer.html` | After page footer content |
249-
| `layouts/partials/docs/inject/menu-before.html` | At the beginning of `<nav>` menu block |
250-
| `layouts/partials/docs/inject/menu-after.html` | At the end of `<nav>` menu block |
251-
| `layouts/partials/docs/inject/content-before.html` | Before page content |
252-
| `layouts/partials/docs/inject/content-after.html` | After page content |
253-
| `layouts/partials/docs/inject/toc-before.html` | At the beginning of table of contents block |
254-
| `layouts/partials/docs/inject/toc-after.html` | At the end of table of contents block |
255-
256-
## Extra Customisation
257-
258-
| File | Description |
259-
| ------------------------ | ------------------------------------------------------------------------------------- |
260-
| `static/favicon.png` | Override default favicon |
261-
| `assets/_custom.scss` | Customise or override scss styles |
262-
| `assets/_variables.scss` | Override default SCSS variables |
263-
| `assets/_fonts.scss` | Replace default font with custom fonts (e.g. local files or remote like google fonts) |
264-
| `assets/mermaid.json` | Replace Mermaid initialization config |
265-
| `assets/katex.json` | Replace KaTeX initialization config |
266-
267-
## Plugins
268-
269-
There are a few features implemented as pluggable `scss` styles. Usually these are features that don't make it to the core but can still be useful.
270-
271-
| Plugin | Description |
272-
| --------------------------------- | ----------------------------------------------------------- |
273-
| `assets/plugins/_numbered.scss` | Makes headings in markdown numbered, e.g. `1.1`, `1.2` |
274-
| `assets/plugins/_scrollbars.scss` | Overrides scrollbar styles to look similar across platforms |
275-
| `assets/plugins/_themes.scss` | Experimental: Extra color themes |
276-
277-
To enable plugins, add `@import "plugins/{name}";` to `assets/_custom.scss` in your website root.
278-
279-
## Hugo Internal Templates
280-
281-
There are a few hugo templates inserted in `<head>`
282-
283-
- [Google Analytics](https://gohugo.io/templates/embedded/#google-analytics)
284-
- [Open Graph](https://gohugo.io/templates/embedded/#open-graph)
285-
286-
To disable Open Graph inclusion you can create your own empty file `/layouts/partials/opengraph.html`.
287-
In fact almost empty not quite empty because an empty file looks like absent for HUGO. For example:
288-
```
289-
<!-- -->
290-
```
291-
292-
## Special layouts
293-
294-
There are extra page layouts apart from documentation pages, to apply set `layout: {name}` in page frontmatter
295-
296-
| Layout | Description |
297-
| --------------------------------- | ------------ |
298-
| `landing` | Renders a langing/home page, hides side menus and adds home menu at the top |
299-
| `book` | Renders a single-page with all pages in configured BookSection section |
300-
301-
## Shortcodes
302-
303-
- [Buttons](https://book.alxs.dev/docs/shortcodes/buttons/)
304-
- [Columns](https://book.alxs.dev/docs/shortcodes/columns/)
305-
- [Details](https://book.alxs.dev/docs/shortcodes/details/)
306-
- [Hints](https://book.alxs.dev/docs/shortcodes/hints/)
307-
- [KaTeX](https://book.alxs.dev/docs/shortcodes/katex/)
308-
- [Mermaid](https://book.alxs.dev/docs/shortcodes/mermaid/)
309-
- [Steps](https://book.alxs.dev/docs/shortcodes/steps/)
310-
- [Tabs](https://book.alxs.dev/docs/shortcodes/tabs/)
311-
312-
By default, Goldmark trims unsafe outputs which might prevent some shortcodes from rendering. It is recommended to set `markup.goldmark.renderer.unsafe=true` if you encounter problems.
313-
314-
```toml
315-
[markup.goldmark.renderer]
316-
unsafe = true
317-
```
34+
## Requirements
35+
- [Hugo](https://gohugo.io/installation/) extended edition, v0.158 or higher
31836

319-
If you are using `config.yaml` or `config.json`, consult the [configuration markup](https://gohugo.io/getting-started/configuration-markup/)
37+
## Documentation
38+
Example site is self-documenting at [book.alxs.dev](https://book.alxs.dev)
32039

32140
## Versioning
322-
32341
This theme follows a simple incremental versioning. e.g. `v1.0.0`, `v2.0.0` and so on. Releases will happen on breaking changes.
32442

32543
If you want lower maintenance, use one of the released versions. If you want to live on the bleeding edge of changes, you can use the `main` branch and update your website when needed, this also the default branch.
32644

32745
## Contributing
328-
32946
### [Extra credits to contributors](https://github.com/alex-shpak/hugo-book/graphs/contributors)
330-
33147
Contributions are welcome and I will review and consider pull requests.
33248
Primary goals are:
33349

archetypes/book.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
title: "{{ .Name | humanize | title }}"
3+
layout: book
4+
# bookSearchExclude: false
5+
---

archetypes/landing.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
title: "{{ .Name | humanize | title }}"
3+
layout: landing
4+
# bookSearchExclude: false
5+
---

assets/_main.scss

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ nav ul {
7171
}
7272
}
7373

74+
nav > ul {
75+
margin-bottom: $padding-16;
76+
}
77+
7478
ul.pagination {
7579
display: flex;
7680
justify-content: center;
@@ -336,8 +340,6 @@ body[dir="rtl"] .book-menu {
336340
}
337341

338342
.book-languages {
339-
margin-bottom: $padding-16;
340-
341343
span {
342344
padding: 0;
343345
}

exampleSite/assets/_custom.scss

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,3 @@
55
// @import "plugins/themes";
66

77
@import "plugins/themes";
8-
9-
.book-hero {
10-
min-height: $padding-16 * 24;
11-
align-content: center;
12-
13-
h1 {
14-
font-size: 3em;
15-
}
16-
}

0 commit comments

Comments
 (0)