🔐 Login Required
Jekyll
To create a GitHub repository, set up a Jekyll site, and deploy it to GitHub Pages—all from the command line—follow these steps:
1. Install Git and GitHub CLI¶
Ensure you have Git and GitHub CLI (gh
) installed on your system.
-
Install Git:
-
Install GitHub CLI:
2. Authenticate GitHub CLI¶
Log in to GitHub using the GitHub CLI:
Follow the prompts to authenticate.3. Create a New GitHub Repository¶
Create a new repository on GitHub:
Replacemy-jekyll-site
with your desired repository name.
4. Install Ruby and Jekyll¶
Install Ruby and Jekyll on your system:
-
Install Ruby:
-
Install Jekyll:
5. Create a New Jekyll Site¶
Generate a new Jekyll site using a pre-built theme:
Navigate into the newly created directory:6. Add a Pre-built Jekyll Theme¶
Edit your Gemfile
to add a pre-built Jekyll theme. Here’s an example using the minima
theme:
-
Edit
Add the following line under theGemfile
:gem "jekyll"
line: -
Edit
Add the following:_config.yml
: Open the_config.yml
file:
7. Install Dependencies¶
Install the required gems:
8. Initialize Git and Push to GitHub¶
Initialize a Git repository, add all files, commit, and push to GitHub:
git init
git add .
git commit -m "Initial commit with Jekyll site"
git branch -M main
git remote add origin https://github.com/your-username/my-jekyll-site.git
git push -u origin main
your-username
and my-jekyll-site
with your GitHub username and repository name.
9. Enable GitHub Pages¶
Now, you need to enable GitHub Pages in the repository:
- Set the default branch as the source for GitHub Pages:
Replace
gh api -X PUT /repos/your-username/my-jekyll-site/pages --field 'source={"branch":"main","path":"/"}'
your-username
andmy-jekyll-site
with your GitHub username and repository name.
10. Access Your Site¶
GitHub Pages will build your site. After a few minutes, your site will be available at:
11. Manage Content¶
You can now manage your site by editing files in the _posts
, _config.yml
, and other directories. Changes can be pushed to the main
branch to update the site.
Optional: Custom Domain¶
If you want to use a custom domain, add a CNAME
file in the root directory with your domain name and configure DNS records accordingly.
This setup allows you to deploy and manage your Jekyll site entirely from the command line, leveraging the power of GitHub Pages.
To create a GitHub repository, set up a Jekyll site, and deploy it to GitHub Pages—all from the command line—follow these steps:
1. Install Git and GitHub CLI¶
Ensure you have Git and GitHub CLI (gh
) installed on your system.
-
Install Git:
-
Install GitHub CLI:
2. Authenticate GitHub CLI¶
Log in to GitHub using the GitHub CLI:
Follow the prompts to authenticate.3. Create a New GitHub Repository¶
Create a new repository on GitHub:
Replacemy-jekyll-site
with your desired repository name.
4. Install Ruby and Jekyll¶
Install Ruby and Jekyll on your system:
-
Install Ruby:
-
Install Jekyll:
5. Create a New Jekyll Site¶
Generate a new Jekyll site using a pre-built theme:
Navigate into the newly created directory:6. Add a Pre-built Jekyll Theme¶
Edit your Gemfile
to add a pre-built Jekyll theme. Here’s an example using the minima
theme:
-
Edit
Add the following line under theGemfile
:gem "jekyll"
line: -
Edit
Add the following:_config.yml
: Open the_config.yml
file:
7. Install Dependencies¶
Install the required gems:
8. Initialize Git and Push to GitHub¶
Initialize a Git repository, add all files, commit, and push to GitHub:
git init
git add .
git commit -m "Initial commit with Jekyll site"
git branch -M main
git remote add origin https://github.com/your-username/my-jekyll-site.git
git push -u origin main
your-username
and my-jekyll-site
with your GitHub username and repository name.
9. Enable GitHub Pages¶
Now, you need to enable GitHub Pages in the repository:
- Set the default branch as the source for GitHub Pages:
Replace
gh api -X PUT /repos/your-username/my-jekyll-site/pages --field 'source={"branch":"main","path":"/"}'
your-username
andmy-jekyll-site
with your GitHub username and repository name.
10. Access Your Site¶
GitHub Pages will build your site. After a few minutes, your site will be available at:
11. Manage Content¶
You can now manage your site by editing files in the _posts
, _config.yml
, and other directories. Changes can be pushed to the main
branch to update the site.
Optional: Custom Domain¶
If you want to use a custom domain, add a CNAME
file in the root directory with your domain name and configure DNS records accordingly.
This setup allows you to deploy and manage your Jekyll site entirely from the command line, leveraging the power of GitHub Pages.
The error you're encountering is related to Git detecting a potential ownership issue with the directory you're trying to work in. This often happens when the user running Git does not match the directory's owner, which can be common in environments like Termux on Android.
To resolve this issue, you can mark the directory as a safe directory for Git. Here's how:
1. Mark the Directory as Safe¶
Run the following command to mark your current working directory as safe:
2. Initialize Git Again¶
After marking the directory as safe, you can re-run the Git commands:
git init
git add .
git commit -m "Initial commit with Jekyll site"
git branch -M main
git remote add origin https://github.com/sriramreddydwarampudi/sriramreddydwarampudi.github.io
git push -u origin main
3. Check GitHub Pages Configuration¶
Make sure your repository is set to use GitHub Pages. If not already configured, you can do this via the GitHub website under the repository's settings or using the GitHub CLI:
gh api -X PUT /repos/sriramreddydwarampudi/sriramreddydwarampudi.github.io/pages --field 'source={"branch":"main","path":"/"}'
4. Access Your GitHub Pages Site¶
After pushing your changes, GitHub Pages will build your site. It should be available at:
If you continue to have issues or need further assistance, feel free to ask!
Great to hear that it's working! To add markdown files to your Jekyll site, update your Git repository, and see the changes on your site, follow these steps:
1. Add Markdown Files to Your Jekyll Site¶
-
Navigate to your Jekyll project directory:
-
Create a new Markdown file in the
_posts
directory. Jekyll uses a specific naming convention for blog posts:YYYY-MM-DD-title.md
. For example: -
Write your content using Markdown syntax. Here’s an example:
-
Save and exit the editor.
2. Update Git Repository¶
-
Add the new file to your Git staging area:
-
Commit the changes with a message:
-
Push the changes to your GitHub repository:
3. View the Changes on Your Site¶
Once the changes are pushed, GitHub Pages will automatically rebuild your site. This process may take a few moments. Afterward, your new post should be visible on your site at:
You can navigate to your blog or posts section to see the new content. If you’re using a theme that lists posts on the homepage, the new post should appear there as well.
4. Adding More Content¶
You can repeat the process to add more posts or pages. For pages that are not blog posts (like an About page), you can create a new .md
file in the root directory or a specific folder:
5. Optional: Preview Locally¶
If you want to preview your changes locally before pushing them to GitHub, you can run:
Then open your browser and go tohttp://localhost:4000
to see the site.
This allows you to see the changes immediately without waiting for the GitHub Pages build process.
Yes, you can use the git add .
command to add all changes, including new, modified, and deleted files, to the staging area. This is often referred to as "git add all."
Here’s how you can do it:
1. Add All Changes¶
This command stages all the changes in your working directory.2. Commit the Changes¶
After adding the changes, you can commit them with a message:
3. Push the Changes to GitHub¶
Finally, push the changes to your GitHub repository:
Using git add .
is convenient when you have multiple files to add or when you want to include all changes at once. However, be mindful that it will stage all changes, so ensure that you haven't accidentally modified or added files you don't intend to commit.
The error occurred because you combined multiple Git commands on the same line without separating them correctly. To execute the commands sequentially, you need to use &&
to chain them together. Here's how you can do it:
This will add all changes, commit them with the specified message, and then push the changes to the main
branch.