Jekyll static blog serverless hosting guide: How to deploy to Surge.sh for free?

How to host for free Jekyll Static blog? No need to buy a server or any technical skills, even a novice can get started quickly!

Jekyll + Surge.sh allows you to easily create an efficient blogging platform!

Jekyll static blog serverless hosting guide: How to deploy to Surge.sh for free?

Install the Surge project

Surge.sh is a JavaScript quoting program published by the Node.js platform.

Before using Surge, you need toInstall Node.js on your local computer.

  • Then install Surge through npm.

If you have not installed Surge, the first task is to enter the following command to install it▼

npm install -g surge
  • Now you have all the tools you need to quickly launch a Jekyll website.

Create a new Jekyll site

First, find your existing Jekyll project, or create a new one via the terminal ▼

# 在当前目录创建一个新的 Jekyll 站点
jekyll new ./

For the specific method of building Jekyll, please click the link below to read our carefully prepared Jekyll download and installation tutorial▼

After setting up a local computer and setting up Jekyll, you can access it in your browser with the following command:jekyll serve

jekyll serve
# 服务器地址: http://localhost:4000/
# 服务器运行中... 按下 ctrl-c 可停止。
  • At this point you have successfully run a basic static website.
  • By default, the Jekyll project runs on your local computer, almost ready for deployment to the server.

Compile your Jekyll website

Next, you can compile your Jekyll website into static HTML, CSS, and JavaScript files.

jekyll build

Now, your source code has been compiled into a _site/ table of Contents.

every run jekyll build , these files will be recompiled - they are also the files you want to publish to the web.

Deploy your Jekyll site

You can use the following command to _site/ Publish catalog to the Internet▼

surge _site/

If you have not logged in or registered yet, the system will prompt you to log in or register.

Next, you will get a random subdomain.

You can replace it with something of your own choice, e.g. example-jekyll.surge.sh

surge _site/

email: [email protected]
project path: ~/Sites/jekyll-project/_site
domain: (random-suggestion.surge.sh) example-jekyll.surge.sh

After pressing Enter, you should receive a message confirming that your website has been successfully launched▼

Success! Project is published and running at example-jekyll.surge.sh
  • Well done, your website is now successfully online!

Surge will ask you to enter a domain name by default every time it is deployed.

To skip this step, you can pass the domain name directly to Surge's CLI when running the command.

For example, if your subdomain isvancouver.surge.sh, you can execute the following command ▼

surge _site/ --domain vancouver.surge.sh
  • If you are adding a custom domain name in Surge, you can replace the subdomain name in the above command with your custom domain name.

If you want to switch accounts to log in, you need to log out of your Surge account▼

surge logout

If the following error message appears▼

Deploy Jekyll to Surge.sh to add a custom domain name: Easily build a static website Part 3

Aborted - you do not have permission to publish to xxx. surge.sh
  • The solution is to change the subdomain generated by Surge by default because this subdomain is already occupied.
  • You can add any alphanumeric prefix to the automatically provided URL.

Please Note

Since the subdomain name officially provided by Surge is forced to block search spiders in the robots.txt file (not conducive toSEO), we do not have permission to modify it, so it is not recommended to use it.

We recommend adding a custom domain name to Surge so that your robots.txt file can be modified.

🚀 Want to learn how to deploy Jekyll to Surge.sh and add a custom domain name?

Click the link below to continue reading our guide and easily build your static website▼

Hope Chen Weiliang Blog ( https://www.chenweiliang.com/ ) shared "Jekyll Static Blog Serverless Hosting Strategy: How to deploy to Surge.sh for free?" 》, helpful to you.

Welcome to share the link of this article:https://www.chenweiliang.com/cwl-31655.html

Welcome to the Telegram channel of Chen Weiliang's blog to get the latest updates!

🔔 Be the first to get the valuable "ChatGPT Content Marketing AI Tool Usage Guide" in the channel top directory! 🌟
📚 This guide contains huge value, 🌟This is a rare opportunity, don’t miss it! ⏰⌛💨
Share and like if you like!
Your sharing and likes are our continuous motivation!

 

Comment

Your email address will not be published. Required fields * Callout

scroll to top