# hugo server -D| EN
+------------------+----+
Pages |10 Paginator pages |0 Non-page files |0 Static files |3 Processed images |0 Aliases |1 Sitemaps |1 Cleaned |0Total in 11 ms
Watching for changes in /Users/bep/quickstart/{content,data,layouts,static,themes}Watching for config changes in /Users/bep/quickstart/config.toml
Environment: "development"Serving pages from memory
Running in Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)Press Ctrl+C to stop
baseURL="https://opsbear2.github.io"title="Welcome to Bear2's Secret Garden 💬🐻💬"theme="hugo-geekdoc"pluralizeListTitles=false# Geekdoc required configurationpygmentsUseClasses=truepygmentsCodeFences=truedisablePathToLower=true# Required if you want to render robots.txt templateenableRobotsTXT=true# Needed for mermaid shortcodes[markup][markup.goldmark.renderer]# Needed for mermaid shortcodeunsafe=true[markup.tableOfContents]startLevel=1endLevel=9[taxonomies]tag="tags"
新增文章的流程是在~/content目录下添加内容,一般是markdown格式的文档,你可以在本地目录下手动创建目录或者文章,当然也可以使用hugo new ${dir}/${article},新增内容后使用hugo -D 重新构建静态页,将~/public下的内容提交到Github
为了解放双手,以上流程已封装成脚本,包括创建文章和推送仓库
create_article.sh 点击Expand展开
#!/bin/sh
# 使用脚本创建新的文章if[$# -ne 2];thenecho"\033[33mUsage: sh $0 dir article\033[0m"exit1fi# 定义文章目录和名称dir=$1article=$2if[ ! -d content/$dir];thenecho"\033[32mInitializing new directory and article ... \033[0m"# 若是新目录,需要创建目录和索引文件 mkdir -p content/$dir&& cp index.md content/$dir/_index.md
first=${dir:0:1}#获取首字母other=${dir:1}#获取其他字母first_upper=$(echo$first| tr 'a-z''A-Z')#将首字符转换为大写title=${first_upper}${other}#拼接首字母大写的目录名称 /usr/local/bin/gsed -i "s/Default/$title/g" content/$dir/_index.md #修改索引文件的title# 获取文章序列号 ls -l content/$dir/*.md |grep -v 'index' >/dev/null
if[$?=0];thennum=$(cd content/$dir&& ls -l *.md |grep -v 'index'| awk '{print $NF}'|awk -F '.''{print $1}'| tail -1)num=$(($num+1))elsenum=1fi# 创建文章 hugo new $dir/${num}.${article}.md
# echo "hugo new $dir/${num}.${article}.md "else# 获取文章序列号 ls -l content/$dir/*.md |grep -v 'index' >/dev/null
if[$?=0];thennum=$(cd content/$dir&& ls -l *.md |grep -v 'index'| awk '{print $NF}'|awk -F '.''{print $1}'| tail -1)num=$(($num+1))elsenum=1fi# 创建文章 hugo new $dir/${num}.${article}.md
# echo "hugo new $dir/${num}.${article}.md "fi
deploy.sh 点击Expand展开
#!/bin/sh
# If a command fails then the deploy stops# set -e# Print out commands before executing them# set -xprintf"\033[0;32mDeploying updates to GitHub...\033[0m\n"# Build the project.hugo -D
# Go To Public foldercd public
# Add changes to git.git add .
# Commit changes.msg="rebuilding site $(date '+%Y-%m-%d %H:%M:%S')"if[ -n "$*"];thenmsg="$*"figit commit -m "$msg"# Push source and build repos.git push origin master