> For the complete documentation index, see [llms.txt](https://vyuka.digitalneumenia.sk/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://vyuka.digitalneumenia.sk/kp-4/01.5-github-pages.md).

# 01.5 - Github Pages

<figure><img src="https://650436139-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPlFhwTej6xICUyFQ9ObW%2Fuploads%2Fbg5llof2KDwOGMMyXs5J%2Fgithub-pages.png?alt=media&amp;token=1a2b52f4-1f86-4cf3-bca5-ebaca7ba0292" alt=""><figcaption></figcaption></figure>

## Uploading Your P5.js Project to GitHub and Publishing with GitHub Pages

In this guide, we’ll walk you through uploading your creative coding project to GitHub and publishing it as a live webpage using GitHub Pages.

### **Why Use GitHub?**

{% embed url="<https://github.com>" %}

GitHub is one of the most popular platforms for developers to store and share their code. It offers version control, collaboration tools, and hosting services, making it an essential tool in the software development world. Here’s why it’s important:

* **Version Control**: GitHub keeps track of changes in your project, so you can revert to earlier versions if needed.
* **Collaboration**: It allows multiple people to work on the same project seamlessly.
* **Portfolio Building**: Sharing your projects on GitHub shows off your skills to potential employers or collaborators.
* **Free Hosting**: With GitHub Pages, you can turn your code into a live website with ease.

By learning GitHub, you’ll be stepping into the larger developer community and adopting practices used in professional environments.

***

### **Step 1: Prepare Your Project Files**

Before starting, download to project from the online editor:\
![](https://650436139-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPlFhwTej6xICUyFQ9ObW%2Fuploads%2F19CfmHLDXGl0KAmsspqT%2FScreenshot%202025-03-09%20at%2023.46.11.png?alt=media\&token=d52dba10-d124-4701-81a7-222c855332a8)

Expand the zipped file and make sure you have the following files ready:

* `index.html`: The main file that displays your webpage.
* `sketch.js`: Your JavaScript file with the creative coding logic (p5.js sketch).
* `style.css`: Optional, for styling your webpage.

Ensure all your files are in one folder.

***

### **Step 2: Create a GitHub Account**

If you don’t already have a GitHub account:

1. Go to github.com.
2. Click **Sign up** and follow the instructions to create an account.
3. After signing up, enroll in the [GitHub Student Developer Pack](https://education.github.com/pack). This pack gives you free access to premium tools and resources, which are great for students starting out in coding. Follow the steps on the website to verify your student status.

{% embed url="<https://education.github.com/pack>" %}

<figure><img src="https://650436139-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPlFhwTej6xICUyFQ9ObW%2Fuploads%2FlCcxGwRN4dp1YbFnda4M%2FScreenshot%202025-03-09%20at%2023.54.10.png?alt=media&amp;token=2094f63a-8a14-4214-b48d-d25e73f2287f" alt=""><figcaption></figcaption></figure>

***

### **Step 3: Create a New Repository**

1. Log in to GitHub.
2. Click the **+** icon in the top-right corner and select **New repository**.\
   ![](https://650436139-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPlFhwTej6xICUyFQ9ObW%2Fuploads%2F7mcSCEeuE7h9Zh8oG5Im%2FScreenshot%202025-03-09%20at%2023.56.13.png?alt=media\&token=87e1db9f-6545-4267-9607-a530a10ba336)
3. Fill out the form:
   * **Repository name**: Name it something like `kp4-perlin`.
   * **Description**: Add a short description of your project (optional).
   * **Visibility**: Select **Public**.
   * Check **Add a README file**.
4. Click **Create repository**.

***

### **Step 4: Upload Your Project Files**

1. In your new repository, click **Add file** > **Upload files**.
2. Drag and drop your project files (`index.html`, `sketch.js`, `style.css`) into the upload area.
3. Scroll down and click **Commit changes** to save your files.

{% hint style="info" %}

> **What Does "Commit Changes" Mean?**
>
> * A "commit" is a snapshot of your project's current state.
> * Committing changes saves the files to your repository and keeps a history of updates.
> * This allows you to track changes over time and revert to previous versions if needed.
>   {% endhint %}

***

### **Step 5: Enable GitHub Pages**

1. Go to your repository’s **Settings** (find this in the top navigation bar).
2. Scroll down to **Pages** in the left-hand menu.
3. Under "Source," select the `main` branch and click **Save**.\
   ![](https://650436139-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPlFhwTej6xICUyFQ9ObW%2Fuploads%2FgAl5z3Q6L0eET3YXr1pl%2FScreenshot%202025-03-10%20at%2000.09.46.png?alt=media\&token=62095993-c381-4957-99b2-eda80a79212a)
4. A green notification will appear with the link to your live webpage (e.g., `https://username.github.io/KP4Perlin`).

<figure><img src="https://650436139-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPlFhwTej6xICUyFQ9ObW%2Fuploads%2Fve7lSumSSqq2CNbWQ4g9%2FScreenshot%202025-03-10%20at%2000.12.56.png?alt=media&amp;token=aff19853-cb2f-4503-aefc-16081ffdee08" alt=""><figcaption></figcaption></figure>

***

### **Step 6: Test Your Webpage**

1. Open the link provided by GitHub Pages.
2. Verify that your sketch is running correctly.

If something isn’t working:

* Check that your `index.html` file references `sketch.js` and `style.css` correctly.
* Refresh the page after a few minutes; GitHub Pages may take some time to update.

***

### **Understanding Your Project Files**

Here’s a breakdown of the main files in your project:

#### **1. `index.html`**

* **Purpose**: The main file for your webpage. Browsers look for this file first.
* **Key Sections**:
  * Links to `sketch.js` and `style.css`.
  * Defines the `<canvas>` element for your sketch.

#### **2. `sketch.js`**

* **Purpose**: Contains your creative coding logic written in JavaScript.
* **Key Responsibilities**:
  * Defines what happens in your p5.js sketch.
  * Handles animations, interactivity, and drawing.

#### **3. `style.css`**

* **Purpose**: Styles your webpage.
* **Key Responsibilities**:
  * Controls colors, fonts, and layout.
  * Example: Change the background color of the page.

***

### **Extra Tips**

* **Editing Files**: You can edit any file directly on GitHub by clicking it and selecting the pencil icon.
* **Customizing Your Page**: Update `style.css` to personalize your project’s appearance.
* **Learning More**: Check out p5.js reference for new ideas and commands.

***

Congratulations! 🎉 You’ve successfully uploaded your project and published it online. Share your GitHub Pages link with others to showcase your work!
