Skip to content

Commit

Permalink
Allow theme to be used as hugo module (#477)
Browse files Browse the repository at this point in the history
* Convert theme to hugo module

* ci: bump PR build too

Signed-off-by: Henry Schreiner <[email protected]>

* Bump hugo SSG to latest version

* Update .github/workflows/ci.yml

---------

Signed-off-by: Henry Schreiner <[email protected]>
Co-authored-by: Henry Schreiner <[email protected]>
  • Loading branch information
deining and henryiii authored Oct 31, 2023
1 parent 7a0d193 commit 62618bd
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 20 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ jobs:
build:
runs-on: ubuntu-latest
env:
HUGO_VERSION: 0.104.2
HUGO_VERSION: 0.120.1
steps:
- name: Install Hugo CLI
run: |
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Pages
id: pages
uses: actions/configure-pages@v2
uses: actions/configure-pages@v3
- name: Build with Hugo
env:
# For maximum backward compatibility with Hugo modules
Expand All @@ -44,7 +44,7 @@ jobs:
-s "./exampleSite/" \
--themesDir "../../"
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
uses: actions/upload-pages-artifact@v2
with:
path: ./exampleSite/public

10 changes: 5 additions & 5 deletions .github/workflows/hugo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ jobs:
build:
runs-on: ubuntu-latest
env:
HUGO_VERSION: 0.104.2
HUGO_VERSION: 0.120.1
steps:
- name: Install Hugo CLI
run: |
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Pages
id: pages
uses: actions/configure-pages@v2
uses: actions/configure-pages@v3
- name: Build with Hugo
env:
# For maximum backward compatibility with Hugo modules
Expand All @@ -51,7 +51,7 @@ jobs:
-s "./exampleSite/" \
--themesDir "../../"
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
uses: actions/upload-pages-artifact@v2
with:
path: ./exampleSite/public

Expand All @@ -69,4 +69,4 @@ jobs:
success()
&& github.ref == 'refs/heads/master'
&& github.repository == 'halogenica/beautifulhugo'
uses: actions/deploy-pages@v1
uses: actions/deploy-pages@v2
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,4 @@ Temporary Items

# Hugo's lock
.hugo_build.lock
exampleSite/public/
25 changes: 22 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,33 @@ See https://hugo-theme-beautifulhugo.netlify.app/

Install Hugo and create a new site. See [the Hugo documentation](https://gohugo.io/getting-started/quick-start/) for details.

Add Beautifulhugo:
### Git Submodule

Add Beautifulhugo as git submodule:

$ git submodule add https://github.com/halogenica/beautifulhugo.git themes/beautifulhugo

### Hugo module

Initialize your site as hugo module:

$ hugo mod init github.com/USERNAME/SITENAME

Add Beautifulhugo module as a dependency of your site:

$ hugo mod get github.com/halogenica/beautifulhugo

### Site preview

Copy the content of `exampleSite` at the root of your project:

cp -r themes/beautifulhugo/exampleSite/* . -iv


If you installed Beautifulhugo as hugo module, set your theme in your config file (hugo.toml):

[[module.imports]]
path = "github.com/halogenica/beautifulhugo"

Start Hugo:

hugo serve
Expand Down Expand Up @@ -56,7 +75,7 @@ pygmentsStyle = "trac"
pygmentsUseClassic = true
```

Pygments is mostly compatable with the newer Chroma. It is slower but has some additional theme options. I recommend Chroma over Pygments. Pygments will use `syntax.css` for highlighting, unless you also set the config `pygmentsUseClasses = false` which will generate the style code directly in the HTML file.
Pygments is mostly compatible with the newer Chroma. It is slower but has some additional theme options. I recommend Chroma over Pygments. Pygments will use `syntax.css` for highlighting, unless you also set the config `pygmentsUseClasses = false` which will generate the style code directly in the HTML file.

#### Highlight.js - Client side syntax highlighting
```
Expand Down
2 changes: 1 addition & 1 deletion exampleSite/content/page/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ What else do you need?

### my history

To be honest, I'm having some trouble remembering right now, so why don't you just watch [my movie](http://en.wikipedia.org/wiki/The_Princess_Bride_%28film%29) and it will answer **all** your questions.
To be honest, I'm having some trouble remembering right now, so why don't you just watch [my movie](https://en.wikipedia.org/wiki/The_Princess_Bride_%28film%29) and it will answer **all** your questions.
4 changes: 2 additions & 2 deletions exampleSite/content/post/2015-02-20-test-markdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ date: 2015-02-20
tags: ["example", "markdown"]
---

You can write regular [markdown](http://markdowntutorial.com/) here and [Hugo](https://gohugo.io) will automatically convert it to a nice webpage. I strongly encourage you to [take 5 minutes to learn how to write in markdown](http://markdowntutorial.com/) - it'll teach you how to transform regular text into bold/italics/headings/tables/etc.
You can write regular [markdown](https://markdowntutorial.com/) here and [Hugo](https://gohugo.io) will automatically convert it to a nice webpage. I strongly encourage you to [take 5 minutes to learn how to write in markdown](https://markdowntutorial.com/) - it'll teach you how to transform regular text into bold/italics/headings/tables/etc.

**Here is some bold text**

Expand All @@ -23,7 +23,7 @@ Here's a useless table:

How about a yummy crepe?

![Crepe](http://s3-media3.fl.yelpcdn.com/bphoto/cQ1Yoa75m2yUFFbY2xwuqw/348s.jpg)
![Crepe](https://s3-media3.fl.yelpcdn.com/bphoto/cQ1Yoa75m2yUFFbY2xwuqw/348s.jpg)

Here's a code chunk with syntax highlighting:

Expand Down
2 changes: 1 addition & 1 deletion exampleSite/content/post/2017-03-05-math-sample.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ $$
\phi = \frac{(1+\sqrt{5})}{2} = 1.6180339887\cdots
$$

Additional details can be found on [GitHub](https://github.com/Khan/KaTeX) or on the [Wiki](http://tiddlywiki.com/plugins/tiddlywiki/katex/).
Additional details can be found on [GitHub](https://github.com/KaTeX/KaTeX) or on the [project homepage](https://katex.org/).
<!--more-->

### Example 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ date: 2017-03-20
tags: ["example", "photoswipe"]
---

Beautiful Hugo adds a few custom shortcodes created by [Li-Wen Yip](https://www.liwen.id.au/heg/) and [Gert-Jan van den Berg](https://github.com/GjjvdBurg/HugoPhotoSwipe) for making galleries with [PhotoSwipe](http://photoswipe.com) .
Beautiful Hugo adds a few custom shortcodes created by [Li-Wen Yip](https://www.liwen.id.au/heg/) and [Gert-Jan van den Berg](https://github.com/GjjvdBurg/HugoPhotoSwipe) for making galleries with [PhotoSwipe](https://photoswipe.com) .

{{< gallery caption-effect="fade" >}}
{{< figure thumb="-thumb" link="/img/hexagon.jpg" >}}
Expand Down
3 changes: 3 additions & 0 deletions exampleSite/config.toml → exampleSite/hugo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
baseurl = "https://username.github.io"
DefaultContentLanguage = "en"
title = "Beautiful Hugo"
# Using theme as git submodule
theme = "beautifulhugo"
# Or when using theme as hugo module
# theme = "github.com/halogenica/beautifulhugo"
pygmentsStyle = "trac"
pygmentsUseClasses = true
pygmentsCodeFences = true
Expand Down
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/halogenica/beautifulhugo

go 1.20
2 changes: 1 addition & 1 deletion netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
command = "cd exampleSite && hugo --gc --themesDir ../.."

[build.environment]
HUGO_VERSION = "0.79.0"
HUGO_VERSION = "0.120.1"
HUGO_THEME = "repo"
HUGO_BASEURL = "/"
4 changes: 2 additions & 2 deletions theme.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ min_version = 0.48

[author]
name = "halogenica"
homepage = "http://halogenica.net"
homepage = "https://halogenica.net"

# If Porting existing theme
[original]
author = "dattali"
homepage = "http://deanattali.com/beautiful-jekyll/"
homepage = "https://beautifuljekyll.com"
repo = "https://github.com/daattali/beautiful-jekyll"

0 comments on commit 62618bd

Please sign in to comment.