Code Monkey home page Code Monkey logo

hugo-theme-logan's Introduction

hugo博客 配置baseUrl的坑

本地启动

  • 不管配置文件怎么改,默认的baseUrl都为localhost,bind的ip为127.0.0.1;
  • 生成的public里的html中的url都不会是你配置文件里的baseUrl
  • -D包含草稿
hugo server -D

除非在后面加上 --baseURL

hugo server -D --baseURL http://www.xxx.com/

启动局域网连接

hugo server -D --bind=0.0.0.0 --port=1313
  • 所以本地开发测试时,不需要关心baseUrl,server启动时就一定是localhost

本地或服务器打包

  • 打包时,hugo会严格按照配置文件中的baseUrl创建静态页面,与--environment无关
  • --gc构建站点时会自动执行垃圾回收;--minify对输出的 HTML、CSS 和 JavaScript 进行压缩和优化
hugo -D --gc --minify

服务器多环境打包

我的博客,同一套代码在github pagesvercel上都有部署,分别是不同的域名,所以就需要区分两个环境的baseUrl,我是这样做的:

  • 把原本的hugo.yaml当作是vercel 的配置,复制原本的配置为hugo_git.yaml当作github pages的配置
  • 两个文件只有baseUrl不同
  • 在启动Hugo打包的时候,需要加具体的配置文件名参数
hugo -D --gc --minify --config hugo.yaml # 在vercel上使用,默认为vercel
hugo -D --gc --minify --config hugo_git.yaml #在github action中使用

hugo-theme-logan's People

Contributors

loganoxo avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.