Deploy the website generated by teedoc to the cloud service provider's web service

Self-built servers require you to purchase your own servers, configure servers, etc. It is not that difficult, but it is a little more complicated. Another option is to use web services provided by cloud service providers.

All we have to do is to upload the generated html page file to the web service of the cloud service provider, and then we can access it through the domain name provided by the cloud service provider. We only need to pay the service provider (usually traffic + number of requests) cost).

For example, the common ones are Alibaba Cloud, Tencent Cloud, AWS, Google Cloud, etc. For example, Alibaba Cloud provides OSS storage services, Tencent Cloud provides COS storage services, and is optimized for static websites, such as those without .html Accessing the link will automatically jump to the page with .html.

Note that some providers do not optimize static pages, and there may be some features that cannot be set. For example, Qiniuyun cannot support links without the end of html, such as /test cannot automatically go to /test.html, And by default, access to / is not automatically transferred to /index.html, and 404.html cannot be read directly from the storage bucket, and needs to be manually uploaded to the configuration of Qiniuyun

Here is Tencent Cloud as an example:

create a bucket

  • Register a Tencent Cloud account and activate the COS storage service
  • Create a bucket, such as teedoc, you will get a bucket name (bucket name), such as teedoc-1250000000, and select the server address, such as region in Guangzhou is ap-guangzhou
  • Enable the static website option in the settings, set the default home page to index.html, set the 404 page to 404.html, if you don't need CDN, you can turn on mandatory HTTPS, so that users will always visit HTTPS sites
  • After setting the static site, you will get a domain name, such as, this domain name is your website domain name, you can access your website through this domain name
  • If you need to customize your own domain name, you can modify the "custom origin site domain name". In fact, it is to set the CNAME record of your domain name to point to this domain name. For example, the CNAME record of points to teedoc-, after setting, you can access your website through
  • In addition, cloud service providers generally support CDN services. If your website has a small number of visits, you don't need to open CDN. If you have a large number of visits, you can open CDN, which can speed up the access speed, but it will increase the cost.

In addition, when setting up CDN, it should be noted that the place of "custom origin site domain name" in the previous step should not be set, but directly set "custom CDN acceleration domain name".

Upload website files

The website file is generated by teedoc, in the out directory, be sure to use the teedoc build command to generate it, not the teedoc serve command to generate it!

Then upload to Tencent Cloud:

teedoc-upload --progress raw --cloud tencent --region ... --bucket ... --secret_id ... --secret_key ... out

Here ... fill in the corresponding information, secret_id and secret_key click on the console avatar -> select access management -> API key management -> create key, then you can see it, you can consider creating a special one Sub-account, and then only give this sub-account COS permissions, which can ensure a certain degree of security.

In addition, if the progress bar cannot be printed in the automatic build system, add the parameter --progress raw; and the secret key is best hidden, for example, the action of github provides the function of secret:

teedoc-upload --progress raw --cloud tencent --region ${{ secrets.TENCENT_REGION }} --bucket ${{ secrets.TENCENT_BUCKET }} --secret_id ${{ secrets.TENCENT_SECRET_ID }} --secret_key ${{ secrets.TENCENT_SECRET_KEY }} out

Update website files

After uploading a file for the first time, you do not need to upload all the files every time in the future, you only need to upload the updated files, which can save time and traffic, such as:

teedoc-upload --progress raw --cloud tencent --region ... --bucket ... --secret_id ... --secret_key ... old_out out

Here old_out is the website file generated last time, out is the website file generated this time, teedoc-upload will automatically compare the two folders, and then upload only the updated file.