Skip to content

🔐 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:

    sudo apt-get install git
    

  • Install GitHub CLI:

    sudo apt-get install gh
    

2. Authenticate GitHub CLI

Log in to GitHub using the GitHub CLI:

gh auth login
Follow the prompts to authenticate.

3. Create a New GitHub Repository

Create a new repository on GitHub:

gh repo create my-jekyll-site --public --confirm
Replace my-jekyll-site with your desired repository name.

4. Install Ruby and Jekyll

Install Ruby and Jekyll on your system:

  • Install Ruby:

    sudo apt-get install ruby-full
    

  • Install Jekyll:

    gem install jekyll bundler
    

5. Create a New Jekyll Site

Generate a new Jekyll site using a pre-built theme:

jekyll new my-jekyll-site --force
Navigate into the newly created directory:
cd my-jekyll-site

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 Gemfile:

    nano Gemfile
    
    Add the following line under the gem "jekyll" line:
    gem "minima"
    

  • Edit _config.yml: Open the _config.yml file:

    nano _config.yml
    
    Add the following:
    theme: minima
    

7. Install Dependencies

Install the required gems:

bundle install

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
Replace 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:
    gh api -X PUT /repos/your-username/my-jekyll-site/pages --field 'source={"branch":"main","path":"/"}'
    
    Replace your-username and my-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:

https://your-username.github.io/my-jekyll-site/

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:

    sudo apt-get install git
    

  • Install GitHub CLI:

    sudo apt-get install gh
    

2. Authenticate GitHub CLI

Log in to GitHub using the GitHub CLI:

gh auth login
Follow the prompts to authenticate.

3. Create a New GitHub Repository

Create a new repository on GitHub:

gh repo create my-jekyll-site --public --confirm
Replace my-jekyll-site with your desired repository name.

4. Install Ruby and Jekyll

Install Ruby and Jekyll on your system:

  • Install Ruby:

    sudo apt-get install ruby-full
    

  • Install Jekyll:

    gem install jekyll bundler
    

5. Create a New Jekyll Site

Generate a new Jekyll site using a pre-built theme:

jekyll new my-jekyll-site --force
Navigate into the newly created directory:
cd my-jekyll-site

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 Gemfile:

    nano Gemfile
    
    Add the following line under the gem "jekyll" line:
    gem "minima"
    

  • Edit _config.yml: Open the _config.yml file:

    nano _config.yml
    
    Add the following:
    theme: minima
    

7. Install Dependencies

Install the required gems:

bundle install

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
Replace 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:
    gh api -X PUT /repos/your-username/my-jekyll-site/pages --field 'source={"branch":"main","path":"/"}'
    
    Replace your-username and my-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:

https://your-username.github.io/my-jekyll-site/

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:

git config --global --add safe.directory /storage/emulated/0/jekyll/second_brain

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:

https://sriramreddydwarampudi.github.io/

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:

    cd /storage/emulated/0/jekyll/second_brain
    

  • 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:

    nano _posts/2024-08-14-my-first-post.md
    

  • Write your content using Markdown syntax. Here’s an example:

    ---
    layout: post
    title: "My First Post"
    date: 2024-08-14 12:00:00 +0530
    categories: jekyll update
    ---
    
    # Welcome to My Jekyll Site
    
    This is my first post on my Jekyll-powered GitHub Pages site.
    

  • Save and exit the editor.

2. Update Git Repository

  • Add the new file to your Git staging area:

    git add _posts/2024-08-14-my-first-post.md
    

  • Commit the changes with a message:

    git commit -m "Added my first blog post"
    

  • Push the changes to your GitHub repository:

    git push origin main
    

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:

https://sriramreddydwarampudi.github.io/

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:

nano about.md
And then commit and push the changes as before.

5. Optional: Preview Locally

If you want to preview your changes locally before pushing them to GitHub, you can run:

bundle exec jekyll serve
Then open your browser and go to http://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

git add .
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:

git commit -m "Updated site with new content"

3. Push the Changes to GitHub

Finally, push the changes to your GitHub repository:

git push origin main

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:

git add . && git commit -m "Updated site with new content" && git push origin main

This will add all changes, commit them with the specified message, and then push the changes to the main branch.