Skip to content

ego/ego.github.io

Repository files navigation

Personal web blog at ego.systemdef.com

Prerequisites

Make sure your were installed

Static site tool

Hugo Github Hugo Hugo quick start

Theme templates

Current Theme

Upgraded Ego Hugo theme Next

Click the green button which name call Use this template. After do that click the green button which name call Create repository from template, then will create your site code automatic.

Remember that need use git submodule command to pull all things from hugo-theme-next at first time.

# First time
git submodule add https://github.com/ego/hugo-theme-next.git themes/hugo-theme-next
git submodule update --init --recursive
# Next time
git submodule update --remote --merge

Update Theme

./scripts/update-ego-hugo-theme-next.sh
git add .
git commit -m "Update theme up to `cat themes/hugo-theme-next/VERSION`"
git push

Update forked customized Theme

Update ego/hugo-theme-next from upstream/hugo-theme-next

Main branch is main

git remote add upstream https://github.com/hugo-next/hugo-theme-next.git
git fetch --all
git checkout develop/ego
git merge upstream/main
git push origin develop/ego

Local development

Just run

./scripts/hugo-run-server.sh

and visit http://localhost:1414/.

New Post

It is recommended to use the following Hugo command to quickly create a new post

# Note
hugo new note/{full-url}.md

# Template
hugo new {root-category}/{second-category}/{main-tags}/{full-url}.md --debug --verbose

# Engineering
hugo new engineering/git/code-stats-metrics/code-stats-metrics-analytics-and-tools.md \
  && mkdir -p engineering/git/code-stats-metrics/assets

# Projects
hugo new projects/{main-category}/{main-tags}/{full-url}.md

# AI
hugo new ai/{main-category}/{main-tags}/{full-url}.md

# Open source
hugo new open-source/{main-category}/{main-tags}/{full-url}.md

# Courses
hugo new courses/{main-category}/{main-tags}/{full-url}.md

# Books
hugo new books/{main-category}/{main-tags}/{full-url}.md

Note By defalut hugo new command will create new post under content root directory, so in here posts were you custom subfolder in content directory.

Archetypes are content template files. Archetypes

All front matter parameter's description in post as below:

---
title: "{{ replace .Name "-" " " | title }}"
description: "{{ .Name }}"
keywords: "{{replace .Name "-" ","}}"
date: {{ .Date }}
lastmod: {{ .Date }}
categories:
  -
tags:
  -
# Post's origin author name
author:
# Post's origin link URL
link:
# Image source link that will use in open graph and twitter card
imgs:
# Expand content on the home page
expand: true
# It's means that will redirecting to external links
extlink:
# Disabled comment plugins in this post
comment:
  enable: false
# Disable table of content int this post
# Notice: By default will automatic build table of content
# with h2-h4 title in post and without other settings
toc: false
# Absolute link for visit
url: "{{ lower .Name }}.html"
# Sticky post set-top in home page and the smaller nubmer will more forward.
weight: 1
# Support Math Formulas render, options: mathjax, katex
math: mathjax
# Enable chart render, such as: flow, sequence, classes etc
mermaid: true

# Custom page params:
js:
  - "1.js"
---

Deployment

GitHub Pages

  • Github Pages
  • Hugo hosting on github
  • Github Actions .github/workflows/gh-pages.yml
  • Edit production config file config/_default/params.yaml before deploy, such as comment, analytis, share and so on.

Published to

Make the release.

./scripts/release.sh

Tools

Custom shortcode templates

Code from file

{{< read_code src="post/engineering/bit-computing-compilers-and-hardware/logic_gate_full_adder_8_bit.py" hl_lines="4-8" >}}

PyScript

{{< read_code src="/note/test.py" >}}

{{< expand_block "<b style='color: #5bd3eb;'>REPL test.py</b>" >}}

{{< iframe_srcdoc >}}
{{< pyscript/js >}}

{{< pyscript/py-repl >}}
{{< read_file src="/note/test.py" >}}
{{< /pyscript/py-repl >}}

{{< /iframe_srcdoc >}}
{{< /read_code >}}

{{< /expand_block >}}

iframe

Python venv

python3 -m venv .env
source .env/bin/activate
pip install -r requirements.txt

Auto generate keywords and tags for post.

./tools/post-keywords-tags.py

GoHugo documentation

License

MIT License