|
| 1 | +# dericbourg.dev |
| 2 | + |
| 3 | +Professional website, built with [Hugo](https://gohugo.io/). |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +- [Docker](https://docs.docker.com/get-docker/) and Docker Compose |
| 8 | +- Make (optional, but recommended) |
| 9 | + |
| 10 | +## Local development |
| 11 | + |
| 12 | +### With Make (recommended) |
| 13 | + |
| 14 | +```bash |
| 15 | +# Start the development server (http://localhost:1313) |
| 16 | +make serve |
| 17 | + |
| 18 | +# Get an interactive shell with Hugo |
| 19 | +make shell |
| 20 | + |
| 21 | +# Rebuild the Docker image |
| 22 | +make build |
| 23 | + |
| 24 | +# Clean up Docker images |
| 25 | +make clean |
| 26 | +``` |
| 27 | + |
| 28 | +### Without Make |
| 29 | + |
| 30 | +```bash |
| 31 | +# Generate the .env file (needed once) |
| 32 | +echo "HUGO_VERSION=$(cat .hugo-version)" > .env |
| 33 | +echo "GO_VERSION=$(cat .go-version)" >> .env |
| 34 | + |
| 35 | +# Start the development server |
| 36 | +docker compose up hugo |
| 37 | + |
| 38 | +# Get an interactive shell |
| 39 | +docker compose run --rm shell |
| 40 | +``` |
| 41 | + |
| 42 | +### Useful Hugo commands |
| 43 | + |
| 44 | +Once in the shell (`make shell`), you can use Hugo directly: |
| 45 | + |
| 46 | +```bash |
| 47 | +# Create new content |
| 48 | +hugo new content/posts/my-article.md |
| 49 | + |
| 50 | +# Build the site (generates in /public) |
| 51 | +hugo |
| 52 | + |
| 53 | +# Build with minification |
| 54 | +hugo --minify |
| 55 | +``` |
| 56 | + |
| 57 | +## Version management |
| 58 | + |
| 59 | +The Hugo and Go versions are centralized in dedicated files: |
| 60 | + |
| 61 | +| File | Description | |
| 62 | +|------|-------------| |
| 63 | +| `.hugo-version` | Hugo version (used by Makefile and GitHub Actions) | |
| 64 | +| `.go-version` | Go version (required for Hugo Modules) | |
| 65 | + |
| 66 | +To update versions: |
| 67 | + |
| 68 | +```bash |
| 69 | +echo "0.150.0" > .hugo-version |
| 70 | +echo "1.24.5" > .go-version |
| 71 | +make build # Rebuild the Docker image |
| 72 | +``` |
| 73 | + |
| 74 | +## Deployment |
| 75 | + |
| 76 | +The site is automatically deployed to GitHub Pages on push to the `main` branch. |
| 77 | + |
| 78 | +### GitHub Actions workflow |
| 79 | + |
| 80 | +The `.github/workflows/hugo.yaml` file defines the deployment pipeline: |
| 81 | + |
| 82 | +1. **Checkout**: Retrieves the source code with submodules (theme) |
| 83 | +2. **Read Hugo version**: Reads `.hugo-version` to ensure consistency with local development |
| 84 | +3. **Install Hugo**: Downloads and installs Hugo Extended |
| 85 | +4. **Build**: Generates the static site with `hugo --gc --minify` |
| 86 | +5. **Deploy**: Publishes to GitHub Pages |
| 87 | + |
| 88 | +## Project structure |
| 89 | + |
| 90 | +``` |
| 91 | +. |
| 92 | +├── .hugo-version # Hugo version (single source of truth) |
| 93 | +├── .go-version # Go version (for Hugo Modules) |
| 94 | +├── hugo.toml # Hugo configuration |
| 95 | +├── go.mod # Hugo Modules dependencies |
| 96 | +├── content/ # Site content (Markdown) |
| 97 | +├── static/ # Static files (images, etc.) |
| 98 | +├── Dockerfile # Docker image for Hugo + Go |
| 99 | +├── docker-compose.yaml # Docker services (hugo, shell) |
| 100 | +└── Makefile # Development commands |
| 101 | +``` |
0 commit comments