adamduncan / eleventy-plugin-i18n

Eleventy plugin to assist with internationalization and dictionary translations
MIT License
103 stars 10 forks source link

How to deploy multiple languages site with caddy? #14

Closed loongmxbt closed 3 years ago

loongmxbt commented 3 years ago

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.

  2. 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!

loongmxbt commented 3 years ago

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
}
adamduncan commented 3 years ago

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