jekyll部署到服务器

  1. 特别需要注意的一点是,jekyll serve命令是一个启动本地服务的命令,这时若你在_config.yaml文件中修改url值,那么你在启动jekyll serve命令之后其服务地址为你本机的地址即localhost或者0.0.0.0,端口号为4000.即你的配置文件中的url值相对于这个命令来说是无效的,但是baseurl仍然生效。_config.yaml配置一般如下。
site_name: 朱容波教授课题组
title: 朱容波教授课题组
locale: en_CN
url: "http://localhost:80"
enforce_ssl:
baseurl: ""
permalink: "/:year/:title.html"
  1. 在jekyll中,默认的环境为开发环境,但是官方文档中对site.url这个变量的定义为:
    Contains the url of your site as it is configured in the _config.yml. For example, if you have url: http://mysite.com in your configuration file, then it will be accessible in Liquid as site.url. For the development environment there is an exception, if you are running jekyll serve in a development environment site.url will be set to the value of host, port, and SSL-related options. This defaults to url: http://localhost:4000。
    即需要在生产环境中才可以将网站的url更改为_config.yaml中配置的url。此时需要在项目中配置一个yaml文件在其中写入以下内容:
build:
  preview_command: bundle exec jekyll build --drafts --unpublished --future -d _site
  publish_command: bundle exec jekyll build -d _site
  preview_env:
  - JEKYLL_ENV=staging
  publish_env:
  - JEKYLL_ENV=production
  preview_output_directory: _site
  output_directory: _site
  instant_preview_command: bundle exec jekyll serve --drafts --unpublished --future
    --port 80 --host 0.0.0.0 -d _site
  1. 使用jekyll build -d 你的输出路径命令将写好的网站编译到相应的路径中。
  2. 在你的服务器上安装nginx,并修改conf/nginx.conf中的内容。
server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   jekyll输出的文件的路径(_site文件夹的路径);//一般不建议用这个
            index  index.html index.htm;
        }

          location /aiot/ {//可以将aiot改为任何你想定义的路径
           alias jekyll输出的文件的路径(_site文件夹的路径)/; //建议用这个,后面不要忘了加/
       }

        # location /aiot {
        #     alias D:/nginx-1.20.2/static/;
        # }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
  1. 建议你在_config.yaml文件中修改baseurl的值,一般设置为你在nginx中配置的路径。不要忘记开放服务器的80端口。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值