Ɲinifɛnw Ɲɛnabɔli (Seo) .

Sariyakolo

i18n.site bɛ ɲɛ kelen jɔcogo dɔ ta min tɛ lakurayali ye Walasa ka ɲinini index (sɛgɛsɛgɛli index) nɔgɔya, ɲɛ jɔlen ni sitemap.xml danfaralen bɛna dilan walasa sɛgɛsɛgɛlikɛlaw ka se ka sɛgɛsɛgɛli kɛ.

Ni User-Agent min bɛ sɔrɔ ɲinini na ɲininikɛlan fɛ, o ɲinini bɛna Lasegin ka Taa ɲɛ jɔlen na 302 fɛ.

Ɲɛ jɔlenw kan, baara kɛ ni link walasa ka jɛgɛnsira jira minnu bɛ nin ɲɛ in kan suguya wɛrɛw la, i n’a fɔ :

<link rel=alternate hreflang=zh href="https://i18n.site/zh/.htm">
<link rel=alternate hreflang=en href="https://i18n.site/en/.htm">

Sigida nginx Labɛncogo

Aw ye .i18n/htm/main.yml labɛncogo filen min bɛ demo poroze kɔnɔ, o ta ka kɛ misali ye

host: i18n-demo.github.io
seo: true
out:
  - fs

pkg:
  i: i18n.site
  md: i18n.site

cdn:
  v:
  jsd:

Aw ye fɔlɔ ka host: nafa caman sɛmɛntiya sanfɛ ka kɛ aw ka domani tɔgɔ ye, i n’a fɔ xxx.com .

O kɔ fɛ, i18n.site -n , ɲɛ jɔlen bɛna Dabɔ out/main/htm ɲɛbilasɛbɛn kɔnɔ.

Tiɲɛ don, i bɛ se fana ka labɛncogo-dosiyɛri wɛrɛw Kɛ, i n’a fɔ fɔlɔ ka main labɛncogo Lajɛ walasa ka .i18n/htm/dist.package.json ni .i18n/htm/dist.yml Dabɔ.

o kɔfɛ , aw bɛ i18n.site -n -c dist boli walasa ɲɛ jɔlen ka sɔrɔ ka kɛ out/dist/htm ye .

nginx bɛ se ka sigi sen kan ni i ye a lajɛ cogoya la min bɛ duguma.

map $http_user_agent $botLang {
  "~*baidu|yisou|sogou|360|byte" "/zh";
  "~*facebookexternalhit|slurp|bot|spider|curl" "/en";
  default "";
}

server {
  http2 on;
  listen 443 quic ;
  listen 443 ssl ;
  listen [::]:443 quic ;
  listen [::]:443 ssl ;

  add_header Alt-Svc 'h3=":443";ma=99999;persist=1';

  server_name doc.flashduty.com;

  ssl_certificate /root/.acme.sh/doc.flashduty.com_ecc/fullchain.cer;
  ssl_certificate_key /root/.acme.sh/doc.flashduty.com_ecc/doc.flashduty.com.key;

  root /mnt/doc.flashduty.com;

# Kana sèrvèr baarakɛla ka scriptw cache ka mɛn kojugu
  location = /S.js {
    add_header Cache-Control "max-age=600";
  }

# Aw bɛ cache waati janw sigi nafolo jɔlen wɛrɛw kama
  location ~* \.(js|css|htm|html|md|avif|json|ico|xml|rss|gz|mp4|png|svg|txt|webmanifest)$ {
    add_header Cache-Control "max-age=999999";
  }

# Crawler bɛ baara kɛ ni file static min ye i n’a fɔ a ɲɛ fɔlɔ doncogo, o sigi
  location = / {
    # Ni $botLang
    if ($botLang) {
        return 301 $botLang/flashduty.htm;
    }
    add_header Cache-Control "max-age=600";
    rewrite ^ /index.html break;
  }

# Ɲɛ kelen-kelen bɛɛ ka baarakɛminɛnw labɛncogo
  location / {
    if ($botLang) {
      return 302 $botLang$request_uri.htm;
    }
    add_header Cache-Control "max-age=600";
    rewrite ^ /index.html break;
  }
}

server {
  server_name doc.flashduty.com;
  listen      80;
  listen      [::]:80 ;
  location    / {
    rewrite ^(.+) https://$host$1 permanent;
  }
  location /.well-known/acme-challenge/ {
    root /mnt/doc.flashduty.com/;
  }
}

Fɛnw Marayɔrɔ Labɛn Walasa Ka Dosiye Jɔlenw Bila

Filenw jɔlenw bɛ Se ka Dabɔ sigida la, nka fɛɛrɛ min ka teli ka Kɛ o ye k’u Blà fɛnw marayɔrɔ la.

out min labɛnna sanfɛ, o sɛmɛntiya ka kɛ :

out:
  - s3

O kɔfɛ, ~/.config/i18n.site.yml ladilan ka nin cogoya in fara a kan :

site:
  i18n.site:
    s3:
      - endpoint: s3.eu-central-003.backblazeb2.com
        ak: # access key
        sk: # secret key
        bucket: # bucket name
        # region:

Labɛnni na, aw bɛ i18n.site Changer ka kɛ host: nafa ye .i18n/htm/main.yml kɔnɔ, fɛn caman marayɔrɔw bɛ se ka labɛn s3 jukɔrɔ, wa region foro ye ŋaniyata ye (fɛn marayɔrɔ caman mago tɛ ka nin foro in sigi).

O kɔfɛ, aw bɛ i18n.site -n boli walasa ka porozɛ in bɔ kɛnɛ kan kokura.

N’i ye ~/.config/i18n.site.yml sɛmɛntiya ani n’i b’a fɛ ka segin ka wuli, i ka nin cikan in kɛ poroze jusigilan kɔnɔ walasa ka jiginni cache saniya :

rm -rf .i18n/data/seo .i18n/data/public

Sankaba-Kɔnɔ-Fɛnw Labɛncogo

Domain tɔgɔ min bɛ jate cloudflare

Yɛlɛma Sariyaw

Aw bɛ fɛn caman tigɛli sariyaw fara a kan i n’a fɔ a jiralen bɛ cogo min na jukɔrɔ:

Sariyasen in ye nin ye, i ka kode "i18n.site" sɛmɛntiya ka kɛ i ka domani tɔgɔ ye:

(http.host in {"i18n.site"}) and not (
substring(http.request.uri.path,-3) in {".js" ".gz"} or
substring(http.request.uri.path,-4) in {".htm" ".rss" ".css" ".svg" ".ico" ".png" ".xml" ".txt"} or
substring(http.request.uri.path,-5) in {".html" ".avif" ".json"} or
ends_with(http.request.uri.path,".webmanifest")
)

Caching Sariyaw

Aw bɛ cache sariyaw fara a kan nin cogo la:

(substring(http.request.uri.path,-4) in {".htm" ".rss"}) or ends_with(http.request.uri.path,"/sitemap.xml") or ends_with(http.request.uri.path,".xml.gz")

Sariyaw Bila Sira Wɛrɛ Kan

Aw ye sira tigɛcogo sariyaw sigi nin cogo la, aw bɛ kode "i18n.site" sɛmɛntiya ka kɛ aw ka domani tɔgɔ ye

(http.host in {"i18n.site"}) and not (
substring(http.request.uri.path,-3) in {".js" ".gz"} or
substring(http.request.uri.path,-4) in {".htm" ".rss" ".css" ".svg" ".ico" ".png" ".xml" ".txt"} or
substring(http.request.uri.path,-5) in {".html" ".avif" ".json"} or
ends_with(http.request.uri.path,".webmanifest")
) and (
http.user_agent wildcard "*bot*" or
http.user_agent wildcard "*spider*" or
http.user_agent wildcard "*facebookexternalhit*" or
http.user_agent wildcard "*slurp*" or
http.user_agent wildcard "curl*" or
http.user_agent wildcard "*InspectionTool*"
)

URL redirect Dynamique redirection sugandi, i ka /en sɛmɛntiya redirection sira concat("/en",http.request.uri.path,".htm") kɔnɔ ka kɛ kan kɔrɔ ye i b’a fɛ ɲininikɛlanw ka don min kɔnɔ.

Baidu Intelligent Sankaba Labɛncogo

Ni aw mago bɛ ka baara kɛ Sinuwa jamanaba ye, aw bɛ se ka baara kɛ ni Baidu Smart Cloud ye .

Donanw bɛ bila Baidu Object Storage kɔnɔ, ka siri Baidu Content Distribution Network la.

O kɔ fɛ, sɛbɛnnibolo dabɔ EdgeJS edge service kɔnɔ i n’a fɔ nin cogo in na

const uri = r.uri, p = uri.lastIndexOf(".");
if (
  p < 0 ||
  !"|js|css|htm|html|md|avif|json|ico|xml|rss|gz|mp4|png|svg|txt|webmanifest|".includes(
    "|" + uri.slice(p + 1) + "|",
  )
) {
  const ua = r.headersIn["User-Agent"].toLowerCase()
  if (/facebookexternalhit|slurp|bot|spider|curl/.test(ua)) {
    r.return(
      302,
      (/baidu|yisou|sogou|360|byte/.test(ua) ? "/zh" : "/en") + r.uri + ".htm",
    )
  } else {
    r.uri = "/index.html"
  }
}

r.respHeader(() => {
  const t = [], out = r.headersOut;
  ["Content-MD5", "Age", "Expires", "Last-Modified"].forEach(
    i => delete out[i]
  )
  r.rawHeadersOut.forEach(i => {
    const key = i[0].toLowerCase()
    if (key.startsWith("x-") || key.startsWith("ohc-")) {
      delete out[key]
    }
  })
  out["Cache-Control"] = "max-age=" + 9e5
  // Jaabi kuncɛlenw bɛ se ka sigi ka bɔli debug, i n’a fɔ out.XXX = 'MSG';
})

Debug digi, o kɔ, Publish to the entire network digi.

Baarakɛcogo Kɔrɔlen: Ka Sirako Tila-Tila Ka Kɛɲɛ Ni Marabolow Ka Ɲɛnabɔli Ye

N’i b’a fɛ ka baara kɛ Sinuwa jamanaba kɔnɔ ani fana n’i b’a fɛ ka cloudflare kɛ diɲɛ jamanaw ka taama fu la, i bɛ se ka baara kɛ ni DNS ye ni marabolow ka latigɛ ye.

Misali la cloudflare Huawei Cloud DNS

Jaan caman bɛ cloudflare labɛncogo la, hakilina damadɔw filɛ nin ye minnu ka kan ka kɔlɔsi :

Domɛni Tɔgɔ Bɛ Jate DNS Wɛrɛw La, Baara Kɛcogo cloudflare

Fɔlɔ, i ka domani tɔgɔ gansan dɔ siri cloudflare la, o kɔfɛ, i bɛ SSL/TLS → domani tɔgɔ ladamu kɛ ka domani tɔgɔba in siri o domani tɔgɔ in na.

cloudflare R2 Tɛ Se Ka Sɔrɔ Domani Tɔgɔ Ladamulen Fɛ

Ikomi fɛn marayɔrɔ R2 cloudflare bɛ don a kɔnɔ, o tɛ se ka sɔrɔ ni domani tɔgɔ ye min bɛ kɛ ka kɛɲɛ ni mɔgɔw sago ye, fɛn marayɔrɔ sabanan ka kan ka kɛ ka dosiye jɔlenw bila.

Yan an cloudflare backblaze.com

Aw bɛ bulon dɔ Dabɔ backblaze.com la, ka dosiye o dosiye Blà, ka digi walasa ka dosiye in Lajɛ, ka Friendly URL tɔgɔ Sɔrɔ, o ye f003.backblazeb2.com ye yan.

Domɛni tɔgɔ Changer ka Bɔ CNAME ka Kɛ f003.backblazeb2.com cloudflare la ani ka proxy (proxy) Dabɔ.

Aw bɛ cloudflare ladilan SSL la → kodɔncogo, aw bɛ a bila Full la

Aw bɛ fɛn caman tigɛli sariya fara a kan i n’a fɔ a jiralen bɛ cogo min na jukɔrɔ, aw k’a bila fɔlɔ (fɔlɔ de ka fɔlɔ ka dɔgɔ):

Rewrite to dinamikɛ sugandi ka your_bucketname ladilan concat("/file/your_bucketname",http.request.uri.path) kɔnɔ ka kɛɲɛ ni i ka bulon tɔgɔ ye.

Ka fara o kan, cloudflare jiginni sariya min bɛ sanfɛ, index.html bɛ Changé ka kɛ file/your_bucketname/index.html ye, wa sigicogo wɛrɛw bɛ to o cogo kelen na.