How to Set Up GitHub Pages from Scratch
Setting up a website might sound intimidating, but with GitHub Pages, you can get your marketing site up and running in no time. Whether you’re building a personal brand or launching a campaign microsite, GitHub Pages offers an easy, cost-free way to host your site. Let’s walk through the process of setting up your own GitHub Pages site from scratch!
What You’ll Need
Before you begin, there are a few things you’ll need:
- GitHub account: If you don’t have one, create it at GitHub.com.
- Basic knowledge of HTML or Markdown: You don’t need to be a pro developer, but having a basic understanding of HTML or Markdown will make things easier.
- Optional: Custom domain: If you want to use your own branded domain (instead of the default GitHub domain), you can configure that later.
Step 1: Create a New Repository
First, you need to create a repository where your website files will live. Here’s how:
- Go to GitHub and log into your account.
- Click the “+” sign at the top right corner and select “New repository.”
- Name your repository, ideally “username.github.io” (replace "username" with your GitHub username). This will allow you to use GitHub Pages with your repository.
- Set the repository to public, and don’t initialize with a README for now (you can add one later if needed).
- Click “Create repository.”
Step 2: Add Your Files
Once your repository is set up, you can add the files that will make up your website. If you’re comfortable with code, create an HTML file or use a static site generator like Jekyll. Otherwise, you can also use Markdown files for simple text-based sites. If you want to start simple, here’s how to create an index.html file:
- On your GitHub repository page, click “Add file” and then “Create new file.”
- Name the file “index.html” and add the following basic HTML code:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>My GitHub Pages Site</title> </head> <body> <h1>Welcome to My GitHub Pages Site!</h1> <p>This is a simple website hosted using GitHub Pages.</p> </body> </html>
Click “Commit new file” to save your changes.
Step 3: Enable GitHub Pages
To publish your site, you need to enable GitHub Pages in the repository settings. Here’s how:
- Go to the repository settings (click on “Settings” in the repository menu).
- Scroll down to the “GitHub Pages” section.
- Under “Source,” select the branch “main” (or “master” if that’s what you named your default branch).
- Click “Save.”
GitHub Pages will now generate your website, and in a few moments, you should see a link to your site under the “GitHub Pages” section, typically in the format of “https://username.github.io/.” Congratulations! Your website is now live.
Step 4: Customize Your Site
Now that your basic site is up and running, you can start customizing it. You can:
- Change the content in your HTML files.
- Add more pages (just create new HTML files and link to them).
- Use a static site generator like Jekyll to create more complex layouts and add blog posts.
- Integrate custom CSS or JavaScript for advanced design and functionality.
Optional: Connect a Custom Domain
If you prefer to use your own domain (e.g., "yourbrand.com"), you can set that up easily with GitHub Pages. All you need to do is:
- Buy a domain name through a domain registrar (e.g., GoDaddy, Namecheap, etc.).
- In your GitHub repository settings, go to the “GitHub Pages” section and enter your custom domain name under the “Custom domain” box.
- Update your DNS settings with your domain provider to point to GitHub’s servers. The specific instructions for this will depend on your registrar, but GitHub has detailed documentation for this process.
Setting up a website with GitHub Pages is simple and straightforward. With just a few steps, you can have a fully functional site that’s fast, reliable, and cost-effective. Whether you’re building a landing page, personal portfolio, or marketing microsite, GitHub Pages offers a powerful tool for digital marketers. Best of all, it’s free!