ITSkillsCenter
Développement Web

Guide : Héberger gratuitement votre site sur GitHub Pages

4 min de lecture

Pourquoi GitHub Pages ?

GitHub Pages est un service 100% gratuit qui héberge vos sites web directement depuis un dépôt GitHub. Parfait pour les portfolios, documentations, blogs et sites vitrines. Pas de serveur à gérer, pas de frais d’hébergement.

✅ Ce que vous pouvez héberger gratuitement

  • Sites statiques (HTML, CSS, JavaScript)
  • Sites générés avec Jekyll, Hugo, Gatsby
  • Portfolios et CV en ligne
  • Documentation de projets
  • Blogs personnels

Limites : 1 Go de stockage, 100 Go de bande passante/mois, pas de code serveur (PHP, Node.js côté serveur).

Étape 1 : Créer un compte GitHub

  1. Allez sur github.com et cliquez sur « Sign up »
  2. Choisissez un nom d’utilisateur (ce sera dans votre URL : votrenom.github.io)
  3. Confirmez votre email

Étape 2 : Créer le dépôt pour votre site

Cliquez sur « New repository » et nommez-le exactement :

votrenom.github.io

Remplacez votrenom par votre nom d’utilisateur GitHub. Cochez « Add a README file », puis cliquez sur « Create repository ».

Étape 3 : Ajouter votre site

Cliquez sur « Add file » → « Create new file ». Nommez-le index.html et collez :

<!DOCTYPE html>
<html lang="fr">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Mon Site - Hébergé sur GitHub Pages</title>
    <style>
        * { margin: 0; padding: 0; box-sizing: border-box; }
        body { font-family: 'Segoe UI', sans-serif; background: linear-gradient(135deg, #667eea, #764ba2); min-height: 100vh; display: flex; align-items: center; justify-content: center; }
        .card { background: white; padding: 40px; border-radius: 20px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); text-align: center; max-width: 500px; }
        h1 { color: #333; margin-bottom: 15px; }
        p { color: #666; line-height: 1.8; }
        .btn { display: inline-block; margin-top: 20px; padding: 12px 30px; background: #667eea; color: white; text-decoration: none; border-radius: 25px; }
    </style>
</head>
<body>
    <div class="card">
        <h1>🎉 Mon site est en ligne !</h1>
        <p>Ce site est hébergé gratuitement sur GitHub Pages.</p>
        <a href="#" class="btn">Découvrir</a>
    </div>
</body>
</html>

Cliquez sur « Commit changes ». Attendez 1-2 minutes, puis visitez https://votrenom.github.io.

Étape 4 : Activer GitHub Pages (pour d’autres dépôts)

Pour tout autre dépôt :

  1. Allez dans Settings → Pages
  2. Sous « Source », sélectionnez main et / (root)
  3. Cliquez sur Save
  4. Votre site sera à : votrenom.github.io/nom-du-depot

Ajouter un nom de domaine personnalisé

Pour utiliser votre propre domaine (ex: monsite.sn) :

  1. Dans Settings → Pages → Custom domain, entrez votre domaine
  2. Chez votre registrar DNS, ajoutez ces enregistrements :
    Type A :
    185.199.108.153
    185.199.109.153
    185.199.110.153
    185.199.111.153
    
    Type CNAME : www → votrenom.github.io
  3. Cochez « Enforce HTTPS » (certificat SSL gratuit)

Déployer avec Git en ligne de commande

# Cloner votre dépôt
git clone https://github.com/votrenom/votrenom.github.io.git
cd votrenom.github.io

# Créer vos fichiers
# ... éditez index.html, style.css, script.js

# Pousser les modifications
git add .
git commit -m "Mise à jour du site"
git push origin main
# Le site se met à jour automatiquement en 1-2 minutes

Utiliser un générateur de site statique

🔥 Jekyll (intégré à GitHub Pages)

GitHub Pages supporte Jekyll nativement. Créez un fichier _config.yml :

title: Mon Blog
description: Blog tech depuis Dakar
thème: minima
plugins:
  - jekyll-feed
  - jekyll-seo-tag

Ajoutez vos articles dans un dossier _posts/ au format 2024-01-15-mon-article.md.

Exercice pratique

🎯 Défi : Mettez votre portfolio en ligne en 15 minutes

  1. Créez un dépôt votrenom.github.io
  2. Ajoutez une page d’accueil avec votre photo, bio et compétences
  3. Ajoutez une page projets.html avec 3 projets
  4. Ajoutez une page contact.html avec un formulaire (utilisez Formspree.io pour le traitement)
  5. Partagez le lien dans les commentaires !

Résumé des commandes essentielles

Action Commande / Étape
Créer le dépôt votrenom.github.io
Activer Pages Settings → Pages → main
Domaine custom CNAME + enregistrements A
Déployer git push origin main
HTTPS gratuit Enforce HTTPS dans Settings
Besoin d'un site web ?

Confiez-nous la Création de Votre Site Web

Site vitrine, e-commerce ou application web — nous transformons votre vision en réalité digitale. Accompagnement personnalisé de A à Z.

À partir de 250.000 FCFA
Parlons de Votre Projet
Publicité