Skip to content

Push on GitHub Repo

Configuration

Before pushing your project to GitHub, you need to set your domain name in two files. This ensures your site’s URLs, sitemap, and SEO metadata are correct.

1. Update astro.config.mjs

Open astro.config.mjs in your code editor and change the site value to your domain name.

JSON code:

export default defineConfig({
site: 'https://localhost:4321'
});

Replace https://localhost:4321 with your actual domain name, for example:

export default defineConfig({
site: 'https://yourdomain.com'
});

2. Update src/data/config.json

Open src/data/config.json and change the url field to match.

JSON code:

{
"url": "http://localhost:4321",
"title": "Creative Photo ART",
"description": "Berkarya lah dengan kegilaan yang mahal, bukan berkarya dengan kemahalan yang gila - The ART of Photography.",
"favicon": "/img/astrojs.svg"
}

Change http://localhost:4321 to your domain name. Both files should now have the same URL.


Push to GitHub

1. Create a GitHub Account

If you don’t have one yet, register at github.com. It’s free.

2. Create a New Repository

Once logged in, create a new repository for your project.

Push astro JS website to github repo

Steps:

  1. Click the + button in the top-right, then New repository
  2. Name your repository (for example: blacks-website)
  3. Choose Public or Private
  4. Click Create repository

Don’t check “Add a README file” — you’ll push your existing project files instead.

3. Push Your Project

Open your terminal, navigate to your project folder, and run these commands.

Terminal commands:

Terminal window
git init
git add .
git commit -m "first commit for my astro website"
git remote add origin https://github.com/username/your-repo-name
git push -u origin master

Replace:

  • username — your GitHub username
  • your-repo-name — your repository name

For example:

Terminal window
git remote add origin https://github.com/creativitas/blacks-website
git push -u origin master

4. Authentication

When prompted for credentials:

  • Username: your GitHub username
  • Password: a Personal Access Token (not your GitHub password)

GitHub no longer accepts account passwords for Git operations. You need to create a token.

How to create a Personal Access Token:

  1. GitHub → click your profile picture → Settings
  2. Scroll down → Developer settings
  3. Personal access tokens → Tokens (classic)
  4. Generate new token (classic)
  5. Name it (for example: “Blacks deploy”)
  6. Set expiration (90 days recommended)
  7. Check the repo scope
  8. Click Generate token
  9. Copy the token immediately — you won’t see it again

Paste this token as your password when Git asks.

5. Verify the Push

Go back to your GitHub repository page and refresh. You should see all your project files listed.

Push astro JS website to github repo


Common Problems

ProblemSolution
remote: Repository not foundCheck the URL with git remote -v and re-add it
Support for password authentication was removedUse a Personal Access Token, not your password
failed to push some refsRun git pull origin master --allow-unrelated-histories first
Git not recognizedInstall Git from git-scm.com and restart your terminal
Authentication failedRegenerate your Personal Access Token with the repo scope

Next Step

Your project is now on GitHub. The next step is to deploy it to a hosting provider.

👉 Hosting Deploy — deploy your site to Cloudflare, Netlify, Vercel, or any static host