A static website is a set of HTML/CSS/JS and media files that doesn't contain any server-side logic. It can communicate with the API or serverless functions using AJAX requests to receive and show data, but there are no server-side calculations involved in the page generation.
More and more static websites are generated using front-end frameworks. For instance, Nuxt is a framework based on Vue that allows you to generate a static website. This generation process is necessary for SEO because it's the only way to make sure that search engines will interpret the website correctly.
Click "Create a service" in the top-left corner of your Dashboard to open this window, and choose "Front-end app or static website":
Next, connect your git repository and choose "Static website" in the next window. Now you can enter the directory containing the
index.html file. Usually this is not the root directory of the repository because it's not secure. Also, if you use a front-end framework it probably will be
If you use a framework such as Nuxt, you want to fill in the Build command field to generate the website content before it is launched. Look for your framework in the Frameworks combo-box.
"404 not found" error
This error usually means that Nginx can't find
index.htm file in a directory. Check that you specified the correct directory in deploy settings containing one of these files.
Two most common values for a directory are:
- Empty directory. It means that the index file is located in a root directory of the repository.
distdirectory that is usually created after the build using a command like
npm run build. If you use Vue, Angular, or React as a front-end framework, you want to use this directory.
npm ERR! enoent ENOENT: no such file or directory, open '/opt/build/package.json'
This error means that you don't have a package.json file in a build directory. There are two solutions for this issue depending on your case: