-
-
Notifications
You must be signed in to change notification settings - Fork 533
Dietpi-Software | Hugo: A static-site generator for building websites #6487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mtekman
wants to merge
4
commits into
MichaIng:dev
Choose a base branch
from
mtekman:hugo
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -1018,6 +1018,12 @@ Available commands: | |||||||
aSOFTWARE_DOCS[$software_id]='https://dietpi.com/docs/software/social/#wordpress' | ||||||||
aSOFTWARE_DEPS[$software_id]='88 89 webserver' | ||||||||
#------------------ | ||||||||
software_id=176 | ||||||||
aSOFTWARE_NAME[$software_id]='Hugo' | ||||||||
aSOFTWARE_DESC[$software_id]='A static-site generator for building websites' | ||||||||
aSOFTWARE_CATX[$software_id]=6 | ||||||||
aSOFTWARE_DOCS[$software_id]='https://dietpi.com/docs/software/social/#hugo' | ||||||||
#------------------ | ||||||||
software_id=38 | ||||||||
aSOFTWARE_NAME[$software_id]='FreshRSS' | ||||||||
aSOFTWARE_DESC[$software_id]='self-hosted RSS feed aggregator' | ||||||||
|
@@ -7058,6 +7064,121 @@ _EOF_ | |||||||
/boot/dietpi/func/create_mysql_db wordpress wordpress "$GLOBAL_PW" | ||||||||
fi | ||||||||
|
||||||||
if To_Install 176 # Hugo | ||||||||
then | ||||||||
local hugo_dir=/mnt/dietpi_userdata/hugo | ||||||||
local hugo_sitename=mysite | ||||||||
|
||||||||
G_AGI hugo | ||||||||
G_EXEC mkdir -p "$hugo_dir" | ||||||||
Create_User -d "$hugo_dir" hugo | ||||||||
|
||||||||
G_EXEC cd "$hugo_dir" | ||||||||
if ! [[ -d "${hugo_dir}/${hugo_sitename}" ]]; then | ||||||||
G_EXEC hugo new site "${hugo_sitename}" -f toml | ||||||||
fi | ||||||||
G_EXEC cd "${hugo_dir}/${hugo_sitename}" | ||||||||
if ! [[ -d themes/paper ]]; then | ||||||||
Download_Install "https://github.com/nanxiaobei/hugo-paper/archive/master.tar.gz" "${hugo_dir}/${hugo_sitename}" | ||||||||
G_EXEC mv "${hugo_dir}/${hugo_sitename}/hugo-paper-main" "${hugo_dir}/${hugo_sitename}/themes/paper" | ||||||||
fi | ||||||||
|
||||||||
cat << _EOF_ > /etc/default/hugo | ||||||||
# Environment variables read by systemd service file /etc/systemd/system/hugo.service | ||||||||
## Toml config path to point to | ||||||||
HUGO_SITEPATH="${hugo_dir}/${hugo_sitename}" | ||||||||
## Domain or address | ||||||||
HUGO_BASEURL="http://$(G_GET_NET ip)" | ||||||||
## Server config | ||||||||
HUGO_PORT="8141" | ||||||||
HUGO_LISTEN="0.0.0.0" | ||||||||
## Inherited by hugo.toml | ||||||||
HUGO_THEME="paper" | ||||||||
_EOF_ | ||||||||
|
||||||||
## Create a default config with a default theme | ||||||||
cat << _EOF_ > "${hugo_dir}"/"${hugo_sitename}"/hugo.toml | ||||||||
title = "DietPi Initial Blog" | ||||||||
languageCode = 'en-us' | ||||||||
|
||||||||
[markup.goldmark.renderer] | ||||||||
unsafe = true | ||||||||
|
||||||||
_EOF_ | ||||||||
|
||||||||
## Create a systemd file | ||||||||
cat << '_EOF_' > /etc/systemd/system/hugo.service | ||||||||
[Unit] | ||||||||
Description=Hugo Static Webserver service | ||||||||
Wants=network-online.target | ||||||||
After=network-online.target | ||||||||
|
||||||||
[Service] | ||||||||
EnvironmentFile=/etc/default/hugo | ||||||||
SyslogIdentifier=Hugo | ||||||||
User=hugo | ||||||||
LogsDirectory=hugo | ||||||||
WorkingDirectory=/mnt/dietpi_userdata/hugo/ | ||||||||
ExecStart=/usr/bin/hugo server -s "${HUGO_SITEPATH}" -p "${HUGO_PORT}" -b "${HUGO_BASEURL}" -t "${HUGO_THEME}" --bind "${HUGO_LISTEN}" --buildDrafts --navigateToChanged | ||||||||
|
||||||||
[Install] | ||||||||
WantedBy=multi-user.target | ||||||||
|
||||||||
_EOF_ | ||||||||
|
||||||||
## Create first post | ||||||||
G_EXEC mkdir -p "${hugo_dir}/${hugo_sitename}/content/posts/" | ||||||||
cat << _EOF_ > "${hugo_dir}/${hugo_sitename}/content/posts/first.md" | ||||||||
--- | ||||||||
title: "First Post" | ||||||||
date: $(date +%Y-%m-%d) | ||||||||
draft: false | ||||||||
--- | ||||||||
# The website is up! | ||||||||
|
||||||||
This is the first post, which was generated by running the command | ||||||||
|
||||||||
cd /mnt/dietpi_userdata/hugo/${hugo_sitename}/ | ||||||||
sudo -u hugo hugo new posts/name-of-post.md | ||||||||
## Note that the '.md' extension is important | ||||||||
|
||||||||
You can then modify the file with a text or markdown editor, and it will | ||||||||
update in real time. e.g. | ||||||||
|
||||||||
sudo -u hugo nano /mnt/dietpi_userdata/hugo/${hugo_sitename}/content/posts/name-of-post.md | ||||||||
|
||||||||
Please also see the [Quick Start](https://gohugo.io/getting-started/quick-start/) | ||||||||
guide for more configuration tips! | ||||||||
|
||||||||
This also allows you to **push** markdown snippets to your DietPi. e.g. | ||||||||
|
||||||||
rsync random-note.md [email protected]:/mnt/dietpi_userdata/hugo/${hugo_sitename}/content/posts/ | ||||||||
|
||||||||
## Extras | ||||||||
|
||||||||
If you are an Emacs fan, you can use the | ||||||||
[ox-hugo](https://ox-hugo.scripter.co/doc/installation/) package to | ||||||||
export an org-mode sub-tree as a post, allowing you to blog on-the-fly | ||||||||
from your editor! | ||||||||
|
||||||||
# Configuration | ||||||||
|
||||||||
Hugo's themes can be changed by editing the "/mnt/dietpi_userdata/hugo/${hugo_sitename}/config.toml" file | ||||||||
See the [Configuration Guide](https://gohugo.io/getting-started/configuration/) for inspiration. | ||||||||
|
||||||||
## Configure a new blog | ||||||||
|
||||||||
If you want your own blog with a different theme and content, just clone the existing and modify the config.toml | ||||||||
|
||||||||
cp -rv /mnt/dietpi_userdata/hugo/${hugo_sitename} /mnt/dietpi_userdata/hugo/my_own_blog | ||||||||
## then edit: /mnt/dietpi_userdata/hugo/my_own_blog/config.toml | ||||||||
|
||||||||
You will also need to update the default blog name (e.g. "my_own_blog") in the "/etc/default/hugo" file, and then restart the hugo service. | ||||||||
|
||||||||
_EOF_ | ||||||||
G_EXEC chown hugo: -R "$hugo_dir" | ||||||||
fi | ||||||||
|
||||||||
if To_Install 38 # FreshRSS | ||||||||
then | ||||||||
# Install required PHP modules: https://github.com/FreshRSS/FreshRSS#requirements | ||||||||
|
@@ -13185,6 +13306,14 @@ _EOF_ | |||||||
Remove_Database wordpress | ||||||||
fi | ||||||||
|
||||||||
if To_Uninstall 176 # Hugo | ||||||||
then | ||||||||
Remove_Service hugo | ||||||||
G_AGP hugo | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe add a warning if purging all user post content is desired? |
||||||||
## Do not remove user post data | ||||||||
## [[ -d '/mnt/dietpi_userdata/hugo' ]] && G_EXEC rm -R /mnt/dietpi_userdata/hugo | ||||||||
fi | ||||||||
|
||||||||
if To_Uninstall 38 # FreshRSS | ||||||||
then | ||||||||
crontab -u www-data -l | grep -v '/opt/FreshRSS/app/actualize_script.php' | crontab -u www-data - | ||||||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it really log to
/var/log/hugo
, or can it be configured to log to STDOUT instead?