adamduncan / eleventy-plugin-i18n

Eleventy plugin to assist with internationalization and dictionary translations

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to deploy multiple languages site with caddy?

loongmxbt opened this issue · comments

Hi, I've successfully serve a multi-language site locally with the plugin. But when I deploy _site to my server I've encountered some problems.

For example there is /en-US and /zh-CN under _site/ directory, and I want the root path / redirect to /en-US.

.
├── css
├── en-US
├── fonts
├── images
├── js
├── revslider
└── zh-CN
  1. In my first caddyfile, there is:
www.demo-site.com {
  root * /var/www/demo-site-html/_site
  encode gzip
  file_server
}

This can go to both /en-US and /zh-CN but cannot go to / because no index.html under _site.

  1. If I change the caddy file into the following:
www.demo-site.com {
  root / /var/www/demo-site-html/_site/en-US
  encode gzip
  file_server
}

I can access to www.demo-site.com/ by default, but cannot access the images and other static files.

So I want to know is there a recommend way to deploy the static i18n site using caddy or nginx? Thanks in advance!

I use this caddyfile with Caddy V2, solves the problem, and if I have other better solutions will post here.

www.demo-site.com {
  root * /var/www/xny-site-html/_site
  encode gzip
  file_server
  redir / /zh-CN/ 302
}

Thanks for sharing @loongmxbt. Yep, I think the redirect would be the way to go