---
metadata:
  - name: generator
    content: Diplodoc Platform v5.54.2
alternate:
  - https://sourcecraft.dev/portal/docs/en/sourcecraft/tutorials/sites.md
  - https://sourcecraft.dev/portal/docs/ru/sourcecraft/tutorials/sites.md
  - href: en/sourcecraft/tutorials/sites.md
    type: text/markdown
    title: Markdown version
  - href: ../../llms.txt
    type: text/markdown
    title: llms.txt
title: Hosting a static website from a repository using SourceCraft Sites
description: Step-by-step guide to configuring static website hosting from a repository using SourceCraft Sites.
---
> **Documentation Index:** Fetch the complete configuration index at https://sourcecraft.dev/portal/docs/en/llms.txt


# Hosting a static website from a repository using SourceCraft Sites

<!-- source: en/_includes/sourcecraft/sites-intro.md -->
_SourceCraft Sites_ is a tool for free static website hosting without the need to configure server infrastructure. Files for a published website are hosted in a public [repository](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/index.md#repos) of a public SourceCraft [organization](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/index.md#org).

A static website is built with such client-side technologies as [HTML](https://en.wikipedia.org/wiki/HTML), [CSS](https://en.wikipedia.org/wiki/CSS), and [JavaScript](https://en.wikipedia.org/wiki/JavaScript). It may not contain any scripts that run on the web server side. You can use any static website generators, e.g., [Jekyll](https://jekyllrb.com/), [Hugo](https://gohugo.io/), [Gatsby](https://www.gatsbyjs.com/), etc.

Access to websites hosted in SourceCraft Sites is arranged over the secure [HTTPS](https://en.wikipedia.org/wiki/HTTPS) protocol. You do not need to upload your own [TLS certificate](https://en.wikipedia.org/wiki/Transport_Layer_Security).

{% note info %}

You can confirm ownership of a SourceCraft Sites website in [Yandex Webmaster](https://webmaster.yandex.com/welcome/). For more information, see [Questions about SourceCraft](https://sourcecraft.dev/portal/docs/en/sourcecraft/qa/sourcecraft-sites.md#verify-site-owner).

{% endnote %}
<!-- endsource: en/_includes/sourcecraft/sites-intro.md -->

In this tutorial, you will configure hosting for a static website from a repository using SourceCraft Sites.

[Learn more about SourceCraft](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/sites.md).

To configure hosting:
1. [Get ready to work](#prepare).
1. [Create a repository from a template](#create).
1. [Edit the original files](#edit).
1. [Test the website](#check).

If you no longer need the website, [unpublish it](#delete).

## Get ready to work {#prepare}

1. Authenticate in SourceCraft on the service [home page](https://sourcecraft.dev) or [sign up](https://sourcecraft.dev/portal/docs/en/sourcecraft/security/registration.md).

    {% note warning %}

    You can only publish a website from a public [repository](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/index.md#repos) in a public [organization](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/index.md#org).
    
    If you are working in a private organization, [update](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/org-edit.md) its visibility settings or [create](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/org-create.md) a new public organization.

    {% endnote %}

1. [Create](https://sourcecraft.dev/portal/docs/en/sourcecraft/security/pat.md#create) a personal access token, as you will need it later.

## Create a repository from a template {#create}

1. Open the [service home page](https://sourcecraft.dev).
1. In the left-hand panel, click ![image](../../_assets/console-icons/plus.svg) **Create repository**.
1. In the window that opens, select **Repository from template**.
1. Click **Use template** next to the [**sites-landing**](https://sourcecraft.dev/sourcecraft/sites-landing) template.
   
   Based on the repository, a [SourceCraft Sites landing page](https://sourcecraft.sourcecraft.site/sites-landing/) is deployed for that template.

   To view the template contents, click **Preview**.

   The template contains a pre-installed [SourceCraft Sites configuration](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/sites.md#config) and standard project files.

1. <!-- source: en/_includes/sourcecraft/repo-create-details.md -->
   Under **Your new repository details**:

   <!-- source: en/_includes/sourcecraft/repo-fork-create-details.md -->
   * In the **Owner** field, select the organization to create the repository in.
   * In the **Name** field, specify a name for the repository. 
          
     The name must be unique within the organization. The name may contain the following [ASCII characters](https://ru.wikipedia.org/wiki/ASCII): lowercase and uppercase Latin letters, numbers, commas, hyphens, and underscores.

     The address to access the repository at is displayed below the name.

   * Optionally, in the **Description** field, enter a description for the repository.
   <!-- endsource: en/_includes/sourcecraft/repo-fork-create-details.md -->
   <!-- endsource: en/_includes/sourcecraft/repo-create-details.md -->

1. In the **Visibility** field, select the **Public** access type for the repository to allow view access to all internet users without authentication. Only invited users will be able to modify the repository.

    {% note warning %}

    You can only publish a website from a public repository in a public organization.
    
    If you are working in a private or internal repository, [update](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/repo-edit.md) its visibility settings or [create](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/repo-create.md) a new public repository.

    {% endnote %}

1. Click **Create repository**.

## Edit the original files {#edit}

1. View the contents of the repository you created.

    The repository contains the following elements for a static website:
    * SourceCraft Sites configuration file, `.sourcecraft/sites.yaml`.
    * [CI/CD](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/ci-cd.md) configuration file, `.sourcecraft/ci.yaml`.
    * Soure files for website generation.

    For more information about the repository structure and technology in use, see [README.md](https://sourcecraft.dev/sourcecraft/sites-landing/browse/README.md).

    The SourceCraft Sites configuration in the repository already such a configuration that makes the template website available at `https://<organization_slug>.sourcecraft.site/<repository_name>` within a few minutes after creating the repository.

1. Click ![image](../../_assets/console-icons/pencil.svg) **Edit** in the top-right corner to edit the `.sourcecraft/sites.yaml` file or keep the default settings.

    <!-- source: en/_includes/sourcecraft/sites-config.md -->
    The SourceCraft Sites configuration is set up for a particular repository and stored in a file named `.sourcecraft/sites.yaml`. A configuration stored in the main branch, e.g., `master` or `main`, applies to the entire repository.

    The general configuration format for SourceCraft Sites in `.sourcecraft/sites.yaml` is as follows: {#config}

    ```yaml
    site:
      root: "<path_to_directory_with_website_files>"
      ref: "<branch_or_tag>"
    ```

    Where:
    * `root`: Absolute path from the repository root to the directory with website files, e.g., `site`. This is an optional setting. By default, it is set to the repository root.

      {% note tip %}

      We recommend using `index.html` for your website homepage.

      {% endnote %}

    * `ref`: Name of branch or tag whose files will be used to publish the static website, e.g., `release`. This is an optional setting. By default, it is set to the repository’s main branch. Once you commit changes to the branch, the website will update automatically in a few minutes.
    <!-- endsource: en/_includes/sourcecraft/sites-config.md -->

1. Similarly, change the contents of the `src` directory, e.g.:
    * Replace the configuration of the website home page, `src/pages/index.yaml`, with the one you need. By default, it contains a configuration for a [SourceCraft Sites landing page](https://sourcecraft.sourcecraft.site/sites-landing/). Do not rename the `index.yaml` file.
    * Add your CSS files or React components. You can see a sample configuration in the `page-builder.config.yml` file.

1. Save the changes in your repository’s main branch.

## Test the website {#check}

According to your `.sourcecraft/ci.yaml` configuration, after making changes in the `main` repository branch, the `build-site` [workflow](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/ci-cd.md#workflows) starts that:
1. Generates website files from the source files in the `src` directory in the `main` branch.
1. Publishes the website files in the `site` directory in the `release` branch.

To test the website:
1. Under ![image](../../_assets/console-icons/code.svg) **Code** on the repository page, go to ![image](../../_assets/console-icons/arrows-3-rotate-right.svg) **CI/CD**.
1. In the list of automation executions, you will see a new execution. Wait for the status to change to ![image](../../_assets/console-icons/circle-check.svg) **Success**.
1. In the left-hand panel on your repository’s home page, follow the link under **Deployments**.

### Build the website locally {#build}

Optionally, you can build and test your website locally:
1. Clone the repository:

    ```bash
    git clone https://git@git.sourcecraft.dev/<organization_slug>/<repository_name>.git
    ```

1. Install [Node.js](https://nodejs.org) version 18 or higher.

    We recommend using [Node Version Manager](https://github.com/nvm-sh/nvm) for installation.

1. Navigate to the repository directory and build the project:

    ```bash
    cd <repository_name>
    npm ci
    npm run build
    ```

1. Open the `site/index.html` project in your browser.

## Unpublish the website {#delete}

If you no longer need the website, remove the contents of the `.sourcecraft/sites.yaml` file in the repository’s main branch or [delete the repository](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/repo-delete.md).
