MalacoWiki

wiki of malacology

hugo

hugo是一个go语言构建的快速静态网页生成器。

注意替换 YOUR_GITHUB_NAME YOUR_DOMAIN YOUR_WEB_ROOT YOUR_CRT_FILE YOUR_KEY_FILE YOUR_SITE。

安装

sudo pacman -S hugo

创建站点

hugo new site YOUR_SITE

安装主题

cd YOUR_SITE/themes
git clone xxx.git 

创建post

hugo new post/new_post

预览

hugo serve

上传服务器

生成ssh key

ssh-keygen -t ed25519 -f ~/.ssh/hugo
cat ~/.ssh/hugo.pub

上传pub到服务器

ssh root@YOUR_DOAMIN
vim ~/.ssh/hugo_authorized
# 输入cat ~/.ssh/hugo.pub内容

your_site根目录创建bash

bash 内容

#! /bin/bash
hugo -D
mv public diary
scp -P 22 -r diary root@YOUR_DOAMIN:YOUR_WEB_ROOT

备份到github

创建private仓库

git init
git add .
git commit -m "new"
git remote add origin https://github.com/YOUR_GITHUB_NAME/YOUR_REPO.git
git push --set-upstream origin master

github page

上传

创建YOUR_GITHUB_NAME.github.io然后选择public,其余不要选

hugo -D
cd public
sudo cp -r * YOUR_WEB_ROOT

从仓库上传

cd /usr/share/nginx/html
sudo git init
sudo git remote add origin https://github.com/YOUR_GITHUB_NAME/YOUR_GITHUB_NAME.github.io.git
sudo git add .
sudo git commit -m "new"
sudo git push

绑定域名

cd YOUR_WEB_ROOT
sudo vim CNAME
---------------
YOUR_DOMAIN
---------------
sudo git add .
sudo git commit -m "update"
sudo git push

解析

主机记录 记录类型 线路类型 记录值
@ CNAME 境外 YOUR_GITHUB_NAME.github.io.

nginx

vim /etc/nginx/sites-enabled/YOUR_SITE.conf

server {
    listen 80;
    server_name YOUR_DOMAIN;
    return 301 https://$host$request_uri;
}
server {
    listen 443 ssl http2;
    server_name YOUR_DOMAIN;
    ssl_certificate YOUR_CRT_FILE;
    ssl_certificate_key YOUR_KEY_FILE;
    ssl_session_cache builtin:1000 shared:SSL:10m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
    ssl_prefer_server_ciphers on;
    access_log /var/log/nginx/access.log;

     location / {
            root   YOUR_WEB_ROOT;
            index  index.html index.htm;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
	    
     }    
}
Last updated on 11 Aug 2021
Published on 11 Aug 2021

Powered by Arch. Copyright by Guoyi.