GitHub Pages
In this page:
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
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
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
# .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
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
ls index.html
# check Settings > Pages for the correct publish source
- गलत branch या folder से publish करना, ताकि site एक 404 दिखाए; repository settings में Pages source check करें।
- एक project site में
/style.cssजैसे absolute paths इस्तेमाल करना, जो टूट जाता है क्योंकि यह/repo/के तहत serve होता है। - यह उम्मीद करना कि 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: