Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Netlifyのプレビュー用URLに合わせてHugoのbaseURLを変更する #11

Closed
kai2nenobu opened this issue Mar 2, 2019 · 1 comment
Labels
hugo Hugoに関する話 netlify Netlifyに関する話

Comments

@kai2nenobu
Copy link
Owner

Netlifyはプルリクに対してプレビュー用の動的なサブドメインを発行してくれる。プルリクからプレビュー用のトップページには遷移できるのだけど、ブログの各記事に飛ぶと、config.tomlbaseURLで設定されているURL(つまりは本番向けのURL)に遷移してしまう。

これはプレビュー用のデプロイでも同じ config.toml を使ってるのでさもありなん、というところ。Netlifyのプレビュー用ドメインに合わせて baseURL を変更する方法を調べる。

@kai2nenobu kai2nenobu added netlify Netlifyに関する話 hugo Hugoに関する話 labels Mar 2, 2019
@kai2nenobu
Copy link
Owner Author

答えはフォーラムに書いてあった。

Hugoは -b, --baseURL オプションで config.tomlbaesURL を上書きできる。なのでNetlifyのビルドコマンドにそれを指定してあげればいい。

フォーラムの例では netlify.toml にコマンドを指定しているが、NetlifyのWebでもできる。具体的には Settings > Build & deplooy > Continuous Deployment > Build settingsBuild commandhugo -b $DEPLOY_URL を指定すればよい。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hugo Hugoに関する話 netlify Netlifyに関する話
Projects
None yet
Development

No branches or pull requests

1 participant