← Back to Git Course | Chapter 9: CI/CD & DevOps | Lesson 5 of 5

GitHub Pages

GitHub Pages एक free bulletin board जैसा है जहाँ आप अपनी website files pin करते हैं और GitHub उन्हें पूरी दुनिया को दिखाता है।
Syntax
bash
git push origin branch_name
git checkout -b gh-pages
git push origin gh-pages

GitHub Pages क्या है

GitHub Pages हर GitHub repository में directly built एक free static-site host है -- HTML, CSS, और JavaScript एक designated branch या folder में push करें, और GitHub इसे बिना किसी अलग hosting account या manage करने के लिए server के एक public URL पर serve करता है।

उदाहरण: What is GitHub Pages

bash
git push origin main
# enable Pages in repository Settings, served at username.github.io/repo

gh-pages Branch Convention

कई पुराने projects और static-site generators एक dedicated gh-pages branch पर publish करते हैं, main से अलग रखा गया ताकि built output source code history के साथ कभी mix न हो -- gh-pages (npm) या Jekyll जैसे tools वहाँ built files push करना automate करते हैं।

उदाहरण: The gh-pages Branch Convention

bash
git checkout -b gh-pages
git push origin gh-pages

Actions-Based Deployment

Modern GitHub Pages setups आमतौर पर एक GitHub Actions workflow इस्तेमाल करते हैं जो site build करता है (जैसे एक static-site generator चलाना) और main पर हर push पर automatically output deploy करता है, पुरानी manual gh-pages-branch workflow को पूरी तरह replace करते हुए।

उदाहरण: Actions-Based Deployment

bash
# .github/workflows/deploy.yml
on:
  push:
    branches: [main]
jobs:
  deploy:
    steps:
      - run: npm run build

Custom Domains

एक GitHub Pages site default github.io URL के बजाय आपके अपने domain से serve की जा सकती है published branch में एक CNAME file add करके और आपके domain के DNS records को GitHub के servers की ओर point करके।

उदाहरण: Custom Domains

bash
echo "www.example.com" > CNAME
git add CNAME
git commit -m "Add custom domain"

एक Pages Build Troubleshoot करना

जब एक Pages deployment fail हो या एक 404 दिखे, दो सबसे common causes हैं repository settings में गलत publish source selected होना, या published branch/folder के root से missing एक index.html -- Actions tab का build log check करना आमतौर पर diagnose करने का सबसे तेज़ तरीका है।

उदाहरण: Troubleshooting a Pages Build

bash
ls index.html
# check Settings > Pages for the correct publish source
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. गलत branch या folder से publish करना, ताकि site एक 404 दिखाए; repository settings में Pages source check करें।
  2. एक project site में /style.css जैसे absolute paths इस्तेमाल करना, जो टूट जाता है क्योंकि यह /repo/ के तहत serve होता है।
  3. यह उम्मीद करना कि Pages PHP या Python जैसा server code चलाएगा, जबकि यह सिर्फ static files serve करता है।
चैप्टर सारांश
  • GitHub Actions और CI/CD pipelines code build और test करना automate करते हैं।
  • Docker integration और deployment workflows applications ship करने में मदद करते हैं।
  • GitHub Pages एक repository से directly static sites host करता है।
🔒

Chapter Quiz — Complete all 5 topics to unlock

0/5 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.