If you don’t have Surge installed, you can install it globally using npm (Node.js package manager). Open your terminal and run the following command:
npm install -g surge
Open your terminal and navigate to the root directory of your static website:
Run the following command to deploy your static site with Surge:
If this is your first time using Surge or if you haven’t logged in before, you’ll be prompted to create a Surge account. Follow the on-screen instructions to sign up.
Follow the prompts to configure your deployment settings:
Once the deployment process is complete, Surge will provide you with a public URL where your static site is now hosted. This will be in the format of
your-project-name.surge.sh or the custom domain you specified.
surge again in your project directory.
surge --domain your-custom-domain.surge.sh.
That’s it! You’ve successfully deployed your static website using Surge. This is a quick and straightforward method for hosting simple static sites. If you need more advanced features or server-side logic, you might want to explore other hosting options.
Here are a few additional tips and information to help you get the most out of Surge:
If you have a custom domain that you’d like to use, you can specify it during deployment or later on. For example:
surge --domain your-custom-domain.com
You’ll need to configure your domain registrar to point to Surge’s servers. Surge provides instructions on how to do this when you set up a custom domain.
Surge creates a
surge file in your project directory to store deployment settings. It also adds a
CNAME file if you’re using a custom domain. If you want to remove your project from Surge, you can use the following command:
This will delete the deployment settings and the associated domain.
Surge provides free SSL for all Surge.sh domains. This means that your website will be served over HTTPS, providing a secure connection for your users.
You can create custom error pages for your Surge deployment. For example, if you want to create a custom 404 error page, create an
index.html file in your project with your custom content and deploy it with Surge.
Surge offers a premium service called Surge Plus, which provides additional features such as unlimited custom domains, SSL for custom domains, and more. You can check the Surge website for pricing and additional information.
surge command has various options that you can use. For example:
--project: Specify the path to your project.
--domain: Specify a custom domain.
--build: Specify a build script or command to run before deploying.
You can view all options by running:
Surge has a web-based dashboard where you can manage your projects, view deployment history, and configure settings. You can access the dashboard by visiting https://surge.sh/account.
Remember that Surge is primarily designed for static sites. If you need server-side logic or have a more complex web application, you might need to explore other hosting options such as Netlify, Vercel, or AWS.