{{ .Version }}
- Reload Page -diff --git a/.circleci/config.yml b/.circleci/config.yml index 30ae14c0c..06e643bdd 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,51 +1,115 @@ -defaults: &defaults - docker: - - image: bepsays/ci-goreleaser:1.11-2 - environment: - CGO_ENABLED: "0" +parameters: +# v2: 11m. +defaults: &defaults + resource_class: large + docker: + - image: bepsays/ci-hugoreleaser:1.22400.20000 +environment: &buildenv + GOMODCACHE: /root/project/gomodcache version: 2 jobs: - build: - <<: *defaults + prepare_release: + <<: *defaults + environment: &buildenv + GOMODCACHE: /root/project/gomodcache steps: - - checkout: + - setup_remote_docker + - checkout: path: hugo + - &git-config + run: + command: | + git config --global user.email "bjorn.erik.pedersen+hugoreleaser@gmail.com" + git config --global user.name "hugoreleaser" - run: - command: | - git clone git@github.com:gohugoio/hugoDocs.git - cd hugo - go mod download - sleep 5 - go test -p 1 ./... - - persist_to_workspace: - root: . - paths: . - release: - <<: *defaults + command: | + cd hugo + go mod download + go run -tags release main.go release --step 1 + - save_cache: + key: git-sha-{{ .Revision }} + paths: + - hugo + - gomodcache + build_container1: + <<: [*defaults] + environment: + <<: [*buildenv] steps: - - attach_workspace: - at: /root/project + - &restore-cache + restore_cache: + key: git-sha-{{ .Revision }} - run: - command: | - cd hugo - git config --global user.email "bjorn.erik.pedersen+hugoreleaser@gmail.com" - git config --global user.name "hugoreleaser" - go run -tags release main.go release -r ${CIRCLE_BRANCH} - + no_output_timeout: 20m + command: | + mkdir -p /tmp/files/dist1 + cd hugo + hugoreleaser build -paths "builds/container1/**" -workers 3 -dist /tmp/files/dist1 -chunks $CIRCLE_NODE_TOTAL -chunk-index $CIRCLE_NODE_INDEX + - &persist-workspace + persist_to_workspace: + root: /tmp/files + paths: + - dist1 + - dist2 + parallelism: 7 + build_container2: + <<: [*defaults] + environment: + <<: [*buildenv] + docker: + - image: bepsays/ci-hugoreleaser-linux-arm64:1.22400.20000 + steps: + - *restore-cache + - &attach-workspace + attach_workspace: + at: /tmp/workspace + - run: + command: | + mkdir -p /tmp/files/dist2 + cd hugo + hugoreleaser build -paths "builds/container2/**" -workers 1 -dist /tmp/files/dist2 + - *persist-workspace + archive_and_release: + <<: [*defaults] + environment: + <<: [*buildenv] + steps: + - *restore-cache + - *attach-workspace + - *git-config + - run: + name: Add github.com to known hosts + command: ssh-keyscan github.com >> ~/.ssh/known_hosts + - run: + command: | + cp -a /tmp/workspace/dist1/. ./hugo/dist + cp -a /tmp/workspace/dist2/. ./hugo/dist + - run: + command: | + cd hugo + hugoreleaser archive + hugoreleaser release + go run -tags release main.go release --step 2 workflows: version: 2 release: jobs: - - build: + - prepare_release: filters: branches: only: /release-.*/ - - hold: - type: approval + - build_container1: requires: - - build - - release: + - prepare_release + - build_container2: + requires: + - prepare_release + - archive_and_release: context: org-global requires: - - hold + - build_container1 + - build_container2 + + + diff --git a/.dockerignore b/.dockerignore index 3342288b4..a183f6fcf 100644 --- a/.dockerignore +++ b/.dockerignore @@ -6,3 +6,4 @@ .circleci docs examples +Dockerfile diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 000000000..fa2791492 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,23 @@ +--- +name: 'Bug report' +labels: 'Bug, NeedsTriage' +assignees: '' +about: Create a report to help us improve +--- + + + + + +### What version of Hugo are you using (`hugo version`)? + +
+$ hugo version + ++ +### Does this issue reproduce with the latest release? diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 000000000..c84d3276b --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,5 @@ +blank_issues_enabled: false +contact_links: + - name: SUPPORT, ISSUES and TROUBLESHOOTING + url: https://discourse.gohugo.io/ + about: Please DO NOT use Github for support requests. Please visit https://discourse.gohugo.io for support! You will be helped much faster there. If you ignore this request your issue might be closed with a discourse label. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 000000000..c114b3d7f --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,11 @@ +--- +name: Proposal +about: Propose a new feature for Hugo +title: '' +labels: 'Proposal, NeedsTriage' +assignees: '' + +--- + + + \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 000000000..1801e72d9 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,7 @@ +# See https://docs.github.com/en/github/administering-a-repository/configuration-options-for-dependency-updates#package-ecosystem +version: 2 +updates: + - package-ecosystem: "gomod" + directory: "/" + schedule: + interval: "daily" diff --git a/.github/stale.yml b/.github/stale.yml deleted file mode 100644 index 692c59659..000000000 --- a/.github/stale.yml +++ /dev/null @@ -1,23 +0,0 @@ -# Number of days of inactivity before an issue becomes stale -daysUntilStale: 120 -# Number of days of inactivity before a stale issue is closed -daysUntilClose: 30 -# Issues with these labels will never be considered stale -exemptLabels: - - Keep - - Security -# Label to use when marking an issue as stale -staleLabel: Stale -# Comment to post when marking an issue as stale. Set to `false` to disable -markComment: > - This issue has been automatically marked as stale because it has not had - recent activity. The resources of the Hugo team are limited, and so we are asking for your help. - - If this is a **bug** and you can still reproduce this error on the
master
branch, please reply with all of the information you have about it in order to keep the issue open.
-
- If this is a **feature request**, and you feel that it is still relevant and valuable, please tell us why.
-
- This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.
-
-# Comment to post when closing a stale issue. Set to `false` to disable
-closeComment: false
diff --git a/.github/workflows/image.yml b/.github/workflows/image.yml
new file mode 100644
index 000000000..c4f3c34c3
--- /dev/null
+++ b/.github/workflows/image.yml
@@ -0,0 +1,49 @@
+name: Build Docker image
+
+on:
+ release:
+ types: [published]
+ pull_request:
+permissions:
+ packages: write
+
+env:
+ REGISTRY_IMAGE: ghcr.io/gohugoio/hugo
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
+
+ - name: Docker meta
+ id: meta
+ uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
+ with:
+ images: ${{ env.REGISTRY_IMAGE }}
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3.6.1
+
+ - name: Login to GHCR
+ # Login is only needed when the image is pushed
+ uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
+ with:
+ registry: ghcr.io
+ username: ${{ github.repository_owner }}
+ password: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Build and push
+ id: build
+ uses: docker/build-push-action@16ebe778df0e7752d2cfcbd924afdbbd89c1a755 # v6.6.1
+ with:
+ context: .
+ provenance: mode=max
+ sbom: true
+ push: ${{ github.event_name != 'pull_request' }}
+ platforms: linux/amd64,linux/arm64
+ tags: ${{ steps.meta.outputs.tags }}
+ labels: ${{ steps.meta.outputs.labels }}
+ build-args: HUGO_BUILD_TAGS=extended,withdeploy
\ No newline at end of file
diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml
new file mode 100644
index 000000000..249c1ab54
--- /dev/null
+++ b/.github/workflows/stale.yml
@@ -0,0 +1,52 @@
+name: 'Close stale and lock closed issues and PRs'
+on:
+ workflow_dispatch:
+ schedule:
+ - cron: '30 1 * * *'
+permissions:
+ contents: read
+jobs:
+ stale:
+ permissions:
+ issues: write
+ pull-requests: write
+ runs-on: ubuntu-latest
+ steps:
+ - uses: dessant/lock-threads@7de207be1d3ce97a9abe6ff1306222982d1ca9f9 # v5.0.1
+ with:
+ issue-inactive-days: 21
+ add-issue-labels: 'Outdated'
+ issue-comment: >
+ This issue has been automatically locked since there
+ has not been any recent activity after it was closed.
+ Please open a new issue for related bugs.
+ pr-comment: >
+ This pull request has been automatically locked since there
+ has not been any recent activity after it was closed.
+ Please open a new issue for related bugs.
+ - uses: actions/stale@28ca1036281a5e5922ead5184a1bbf96e5fc984e # v9.0.0
+ with:
+ operations-per-run: 999
+ days-before-issue-stale: 365
+ days-before-pr-stale: 365
+ days-before-issue-close: 56
+ days-before-pr-close: 56
+ stale-issue-message: >
+ This issue has been automatically marked as stale because it has not had
+ recent activity. The resources of the Hugo team are limited, and so we are asking for your help.
+
+ If this is a **bug** and you can still reproduce this error on the master
branch, please reply with all of the information you have about it in order to keep the issue open.
+
+ If this is a **feature request**, and you feel that it is still relevant and valuable, please tell us why.
+
+ This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.
+ stale-pr-message: This PR has been automatically marked as stale because it has not had
+ recent activity. The resources of the Hugo team are limited, and so we are asking for your help.
+
+ Please check https://github.com/gohugoio/hugo/blob/master/CONTRIBUTING.md#code-contribution and verify that this code contribution fits with the description. If yes, tell is in a comment.
+
+ This PR will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.
+ stale-issue-label: 'Stale'
+ exempt-issue-labels: 'Keep,Security'
+ stale-pr-label: 'Stale'
+ exempt-pr-labels: 'Keep,Security'
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
new file mode 100644
index 000000000..c49c12371
--- /dev/null
+++ b/.github/workflows/test.yml
@@ -0,0 +1,132 @@
+on:
+ push:
+ branches: [master]
+ pull_request:
+name: Test
+env:
+ GOPROXY: https://proxy.golang.org
+ GO111MODULE: on
+ SASS_VERSION: 1.80.3
+ DART_SASS_SHA_LINUX: 7c933edbad0a7d389192c5b79393485c088bd2c4398e32f5754c32af006a9ffd
+ DART_SASS_SHA_MACOS: 79e060b0e131c3bb3c16926bafc371dc33feab122bfa8c01aa337a072097967b
+ DART_SASS_SHA_WINDOWS: 0bc4708b37cd1bac4740e83ac5e3176e66b774f77fd5dd364da5b5cfc9bfb469
+permissions:
+ contents: read
+jobs:
+ test:
+ strategy:
+ matrix:
+ go-version: [1.23.x, 1.24.x]
+ os: [ubuntu-latest, windows-latest] # macos disabled for now because of disk space issues.
+ runs-on: ${{ matrix.os }}
+ steps:
+ - if: matrix.os == 'ubuntu-latest'
+ name: Free Disk Space (Ubuntu)
+ uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1
+ with:
+ # this might remove tools that are actually needed,
+ # if set to "true" but frees about 6 GB
+ tool-cache: false
+ android: true
+ dotnet: true
+ haskell: true
+ large-packages: true
+ docker-images: true
+ swap-storage: true
+ - name: Checkout code
+ uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
+ - name: Install Go
+ uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
+ with:
+ go-version: ${{ matrix.go-version }}
+ check-latest: true
+ cache: true
+ cache-dependency-path: |
+ **/go.sum
+ **/go.mod
+ - name: Install Ruby
+ uses: ruby/setup-ruby@a6e6f86333f0a2523ece813039b8b4be04560854 # v1.190.0
+ with:
+ ruby-version: "2.7"
+ bundler-cache: true #
+ - name: Install Python
+ uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1
+ with:
+ python-version: "3.x"
+ - name: Install Mage
+ run: go install github.com/magefile/mage@v1.15.0
+ - name: Install asciidoctor
+ uses: reitzig/actions-asciidoctor@c642db5eedd1d729bb8c92034770d0b2f769eda6 # v2.0.2
+ - name: Install docutils
+ run: |
+ pip install docutils
+ rst2html --version
+ - if: matrix.os == 'ubuntu-latest'
+ name: Install pandoc on Linux
+ run: |
+ sudo apt-get update -y
+ sudo apt-get install -y pandoc
+ - if: matrix.os == 'macos-latest'
+ run: |
+ brew install pandoc
+ - if: matrix.os == 'windows-latest'
+ run: |
+ choco install pandoc
+ - run: pandoc -v
+ - if: matrix.os == 'windows-latest'
+ run: |
+ choco install mingw
+ - if: matrix.os == 'ubuntu-latest'
+ name: Install dart-sass Linux
+ run: |
+ echo "Install Dart Sass version ${SASS_VERSION} ..."
+ curl -LJO "https://github.com/sass/dart-sass/releases/download/${SASS_VERSION}/dart-sass-${SASS_VERSION}-linux-x64.tar.gz";
+ echo "${DART_SASS_SHA_LINUX} dart-sass-${SASS_VERSION}-linux-x64.tar.gz" | sha256sum -c;
+ tar -xvf "dart-sass-${SASS_VERSION}-linux-x64.tar.gz";
+ echo "$GOBIN"
+ echo "$GITHUB_WORKSPACE/dart-sass/" >> $GITHUB_PATH
+ - if: matrix.os == 'macos-latest'
+ name: Install dart-sass MacOS
+ run: |
+ echo "Install Dart Sass version ${SASS_VERSION} ..."
+ curl -LJO "https://github.com/sass/dart-sass/releases/download/${SASS_VERSION}/dart-sass-${SASS_VERSION}-macos-x64.tar.gz";
+ echo "${DART_SASS_SHA_MACOS} dart-sass-${SASS_VERSION}-macos-x64.tar.gz" | shasum -a 256 -c;
+ tar -xvf "dart-sass-${SASS_VERSION}-macos-x64.tar.gz";
+ echo "$GITHUB_WORKSPACE/dart-sass/" >> $GITHUB_PATH
+ - if: matrix.os == 'windows-latest'
+ name: Install dart-sass Windows
+ run: |
+ echo "Install Dart Sass version ${env:SASS_VERSION} ..."
+ curl -LJO "https://github.com/sass/dart-sass/releases/download/${env:SASS_VERSION}/dart-sass-${env:SASS_VERSION}-windows-x64.zip";
+ Expand-Archive -Path "dart-sass-${env:SASS_VERSION}-windows-x64.zip" -DestinationPath .;
+ echo "$env:GITHUB_WORKSPACE/dart-sass/" | Out-File -FilePath $Env:GITHUB_PATH -Encoding utf-8 -Append
+ - if: matrix.os == 'ubuntu-latest'
+ name: Install staticcheck
+ run: go install honnef.co/go/tools/cmd/staticcheck@latest
+ - if: matrix.os == 'ubuntu-latest'
+ name: Run staticcheck
+ run: staticcheck ./...
+ - if: matrix.os != 'windows-latest'
+ name: Check
+ run: |
+ sass --version;
+ mage -v check;
+ env:
+ HUGO_BUILD_TAGS: extended,withdeploy
+ - if: matrix.os == 'windows-latest'
+ # See issue #11052. We limit the build to regular test (no -race flag) on Windows for now.
+ name: Test
+ run: |
+ mage -v test;
+ env:
+ HUGO_BUILD_TAGS: extended,withdeploy
+ - name: Build tags
+ run: |
+ go install -tags extended
+ - if: matrix.os == 'ubuntu-latest'
+ name: Build for dragonfly
+ run: |
+ go install
+ env:
+ GOARCH: amd64
+ GOOS: dragonfly
diff --git a/.gitignore b/.gitignore
index 568492d85..ddad69611 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,24 +1,6 @@
-hugo
-docs/public*
-/.idea
-hugo.exe
+
*.test
-*.prof
-nohup.out
-cover.out
-*.swp
-*.swo
-.DS_Store
-*~
-vendor/*/
-*.bench
-*.debug
-coverage*.out
-
-dock.sh
-
-GoBuilds
-dist
-
-
-vendor
\ No newline at end of file
+imports.*
+dist/
+public/
+.DS_Store
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index fd5c281fd..000000000
--- a/.travis.yml
+++ /dev/null
@@ -1,44 +0,0 @@
-language: go
-sudo: false
-dist: trusty
-env:
- global:
- - HUGO_BUILD_TAGS="extended"
-git:
- depth: false
-go:
- - 1.11
- - tip
-os:
- - linux
- - osx
- - windows
-matrix:
- allow_failures:
- - go: tip
- fast_finish: true
- exclude:
- - os: windows
- go: tip
-
-install:
- - mkdir -p $HOME/src
- - mv $HOME/gopath/src/github.com/gohugoio/hugo $HOME/src
- - export TRAVIS_BUILD_DIR=$HOME/src/hugo
- - cd $HOME/src/hugo
- - go get github.com/magefile/mage
-script:
- - go mod download
- - mage -v test
- - mage -v check
- - mage -v hugo
- - ./hugo -s docs/
- - ./hugo --renderToMemory -s docs/
- - df -h
-
-before_install:
- - df -h
- # https://travis-ci.community/t/go-cant-find-gcc-with-go1-11-1-on-windows/293/5
- - if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then choco install mingw -y; export PATH=/c/tools/mingw64/bin:"$PATH"; fi
- - gem install asciidoctor
- - type asciidoctor
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 124e5b754..ddd3efcf2 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1,3 +1,5 @@
+>**Note:** We would appreciate if you hold on with any big refactoring (like renaming deprecated Go packages), mainly because of potential for extra merge work for future coming in in the near future.
+
# Contributing to Hugo
We welcome contributions to Hugo of any kind including documentation, themes,
@@ -29,12 +31,16 @@ Please don't use the GitHub issue tracker to ask questions.
## Reporting Issues
If you believe you have found a defect in Hugo or its documentation, use
-the GitHub [issue tracker](https://github.com/gohugoio/hugo/issues) to report
+the GitHub issue tracker to report
the problem to the Hugo maintainers. If you're not sure if it's a bug or not,
start by asking in the [discussion forum](https://discourse.gohugo.io).
When reporting the issue, please provide the version of Hugo in use (`hugo
version`) and your operating system.
+- [Hugo Issues · gohugoio/hugo](https://github.com/gohugoio/hugo/issues)
+- [Hugo Documentation Issues · gohugoio/hugoDocs](https://github.com/gohugoio/hugoDocs/issues)
+- [Hugo Website Theme Issues · gohugoio/hugoThemesSite](https://github.com/gohugoio/hugoThemesSite/issues)
+
## Code Contribution
Hugo has become a fully featured static site generator, so any new functionality must:
@@ -44,15 +50,15 @@ Hugo has become a fully featured static site generator, so any new functionality
* strive not to break existing sites.
* close or update an open [Hugo issue](https://github.com/gohugoio/hugo/issues)
-If it is of some complexity, the contributor is expected to maintain and support the new future (answer questions on the forum, fix any bugs etc.).
+If it is of some complexity, the contributor is expected to maintain and support the new feature in the future (answer questions on the forum, fix any bugs etc.).
-It is recommended to open up a discussion on the [Hugo Forum](https://discourse.gohugo.io/) to get feedback on your idea before you begin. If you are submitting a complex feature, create a small design proposal on the [Hugo issue tracker](https://github.com/gohugoio/hugo/issues) before you start.
+Any non-trivial code change needs to update an open [issue](https://github.com/gohugoio/hugo/issues). A non-trivial code change without an issue reference with one of the labels `bug` or `enhancement` will not be merged.
+Note that we do not accept new features that require [CGO](https://github.com/golang/go/wiki/cgo).
+We have one exception to this rule which is LibSASS.
**Bug fixes are, of course, always welcome.**
-
-
## Submitting Patches
The Hugo project welcomes all contributors and contributions regardless of skill or experience level. If you are interested in helping with the project, we will help you with your contribution.
@@ -75,19 +81,23 @@ To make the contribution process as seamless as possible, we ask for the followi
### Git Commit Message Guidelines
-This [blog article](http://chris.beams.io/posts/git-commit/) is a good resource for learning how to write good commit messages,
+This [blog article](https://cbea.ms/git-commit/) is a good resource for learning how to write good commit messages,
the most important part being that each commit message should have a title/subject in imperative mood starting with a capital letter and no trailing period:
-*"Return error on wrong use of the Paginator"*, **NOT** *"returning some error."*
+*"js: Return error when option x is not set"*, **NOT** *"returning some error."*
+
+Most title/subjects should have a lower-cased prefix with a colon and one whitespace. The prefix can be:
+
+* The name of the package where (most of) the changes are made (e.g. `media: Add text/calendar`)
+* If the package name is deeply nested/long, try to shorten it from the left side, e.g. `markup/goldmark` is OK, `resources/resource_transformers/js` can be shortened to `js`.
+* If this commit touches several packages with a common functional topic, use that as a prefix, e.g. `errors: Resolve correct line numbers`)
+* If this commit touches many packages without a common functional topic, prefix with `all:` (e.g. `all: Reformat Go code`)
+* If this is a documentation update, prefix with `docs:`.
+* If nothing of the above applies, just leave the prefix out.
+* Note that the above excludes nouns seen in other repositories, e.g. "chore:".
Also, if your commit references one or more GitHub issues, always end your commit message body with *See #1234* or *Fixes #1234*.
Replace *1234* with the GitHub issue ID. The last example will close the issue when the commit is merged into *master*.
-Sometimes it makes sense to prefix the commit message with the package name (or docs folder) all lowercased ending with a colon.
-That is fine, but the rest of the rules above apply.
-So it is "tpl: Add emojify template func", not "tpl: add emojify template func.", and "docs: Document emoji", not "doc: document emoji."
-
-Please use a short and descriptive branch name, e.g. **NOT** "patch-1". It's very common but creates a naming conflict each time when a submission is pulled for a review.
-
An example:
```text
@@ -113,12 +123,10 @@ cd hugo
go install
```
->Note: Some Go tools may not be fully updated to support Go Modules yet. One example would be LiteIDE. Follow [this workaround](https://github.com/visualfc/liteide/issues/986#issuecomment-428117702) for how to continue to work with Hugo below `GOPATH`.
-
For some convenient build and test targets, you also will want to install Mage:
```bash
-go get github.com/magefile/mage
+go install github.com/magefile/mage
```
Now, to make a change to Hugo's source:
@@ -140,7 +148,7 @@ Now, to make a change to Hugo's source:
1. Add your fork as a new remote (the remote name, "fork" in this example, is arbitrary):
```bash
- git remote add fork git://github.com/USERNAME/hugo.git
+ git remote add fork git@github.com:USERNAME/hugo.git
```
1. Push the changes to your new remote:
diff --git a/Dockerfile b/Dockerfile
index 2cd4a14d6..a0e34353f 100755
--- a/Dockerfile
+++ b/Dockerfile
@@ -2,25 +2,98 @@
# Twitter: https://twitter.com/gohugoio
# Website: https://gohugo.io/
-FROM golang:1.11-alpine3.7 AS build
+ARG GO_VERSION="1.24"
+ARG ALPINE_VERSION="3.22"
+ARG DART_SASS_VERSION="1.79.3"
-ENV CGO_ENABLED=0
-ENV GOOS=linux
-ENV GO111MODULE=on
+FROM --platform=$BUILDPLATFORM tonistiigi/xx:1.5.0 AS xx
+FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS gobuild
+FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS gorun
+
+
+FROM gobuild AS build
+
+RUN apk add clang lld
+
+# Set up cross-compilation helpers
+COPY --from=xx / /
+
+ARG TARGETPLATFORM
+RUN xx-apk add musl-dev gcc g++
+
+# Optionally set HUGO_BUILD_TAGS to "none" or "withdeploy" when building like so:
+# docker build --build-arg HUGO_BUILD_TAGS=withdeploy .
+#
+# We build the extended version by default.
+ARG HUGO_BUILD_TAGS="extended"
+ENV CGO_ENABLED=1
+ENV GOPROXY=https://proxy.golang.org
+ENV GOCACHE=/root/.cache/go-build
+ENV GOMODCACHE=/go/pkg/mod
+ARG TARGETPLATFORM
WORKDIR /go/src/github.com/gohugoio/hugo
+
+# For --mount=type=cache the value of target is the default cache id, so
+# for the go mod cache it would be good if we could share it with other Go images using the same setup,
+# but the go build cache needs to be per platform.
+# See this comment: https://github.com/moby/buildkit/issues/1706#issuecomment-702238282
+RUN --mount=target=. \
+ --mount=type=cache,target=/go/pkg/mod \
+ --mount=type=cache,target=/root/.cache/go-build,id=go-build-$TARGETPLATFORM <+ -To contribute to the Hugo source code or documentation, you should [fork the Hugo GitHub project](https://github.com/gohugoio/hugo#fork-destination-box) and clone it to your local machine. +## Editions -Finally, you can install the Hugo source code with `go`, build the binaries yourself, and run Hugo that way. -Building the binaries is an easy task for an experienced `go` getter. +Hugo is available in three editions: standard, extended, and extended/deploy. While the standard edition provides core functionality, the extended and extended/deploy editions offer advanced features. -### Install Hugo as Your Site Generator (Binary Install) +Feature|extended edition|extended/deploy edition +:--|:-:|:-: +Encode to the WebP format when [processing images]. You can decode WebP images with any edition.|:heavy_check_mark:|:heavy_check_mark: +[Transpile Sass to CSS] using the embedded LibSass transpiler. You can use the [Dart Sass] transpiler with any edition.|:heavy_check_mark:|:heavy_check_mark: +Deploy your site directly to a Google Cloud Storage bucket, an AWS S3 bucket, or an Azure Storage container. See [details].|:x:|:heavy_check_mark: -Use the [installation instructions in the Hugo documentation](https://gohugo.io/getting-started/installing/). +[dart sass]: https://gohugo.io/functions/css/sass/#dart-sass +[processing images]: https://gohugo.io/content-management/image-processing/ +[transpile sass to css]: https://gohugo.io/functions/css/sass/ +[details]: https://gohugo.io/hosting-and-deployment/hugo-deploy/ -### Build and Install the Binaries from Source (Advanced Install) +Unless your specific deployment needs require the extended/deploy edition, we recommend the extended edition. -#### Prerequisite Tools +## Installation -* [Git](https://git-scm.com/) -* [Go (at least Go 1.11)](https://golang.org/dl/) +Install Hugo from a [prebuilt binary], package manager, or package repository. Please see the installation instructions for your operating system: -#### Fetch from GitHub +- [macOS] +- [Linux] +- [Windows] +- [DragonFly BSD, FreeBSD, NetBSD, and OpenBSD] -Since Hugo 0.48, Hugo uses the Go Modules support built into Go 1.11 to build. The easiest is to clone Hugo in a directory outside of `GOPATH`, as in the following example: +## Build from source -```bash -mkdir $HOME/src -cd $HOME/src -git clone https://github.com/gohugoio/hugo.git -cd hugo -go install +Prerequisites to build Hugo from source: + +- Standard edition: Go 1.23.0 or later +- Extended edition: Go 1.23.0 or later, and GCC +- Extended/deploy edition: Go 1.23.0 or later, and GCC + +Build the standard edition: + +```text +go install github.com/gohugoio/hugo@latest ``` -**If you are a Windows user, substitute the `$HOME` environment variable above with `%USERPROFILE%`.** - -## The Hugo Documentation +Build the extended edition: -The Hugo documentation now lives in its own repository, see https://github.com/gohugoio/hugoDocs. But we do keep a version of that documentation as a `git subtree` in this repository. To build the sub folder `/docs` as a Hugo site, you need to clone this repo: - -```bash -git clone git@github.com:gohugoio/hugo.git +```text +CGO_ENABLED=1 go install -tags extended github.com/gohugoio/hugo@latest ``` -## Contributing to Hugo + +Build the extended/deploy edition: + +```text +CGO_ENABLED=1 go install -tags extended,withdeploy github.com/gohugoio/hugo@latest +``` + +## Star History + +[](https://star-history.com/#gohugoio/hugo&Timeline) + +## Documentation + +Hugo's [documentation] includes installation instructions, a quick start guide, conceptual explanations, reference information, and examples. + +Please submit documentation issues and pull requests to the [documentation repository]. + +## Support + +Please **do not use the issue queue** for questions or troubleshooting. Unless you are certain that your issue is a software defect, use the [forum]. + +Hugo’s [forum] is an active community of users and developers who answer questions, share knowledge, and provide examples. A quick search of over 20,000 topics will often answer your question. Please be sure to read about [requesting help] before asking your first question. + +## Contributing + +You can contribute to the Hugo project by: + +- Answering questions on the [forum] +- Improving the [documentation] +- Monitoring the [issue queue] +- Creating or improving [themes] +- Squashing [bugs] + +Please submit documentation issues and pull requests to the [documentation repository]. + +If you have an idea for an enhancement or new feature, create a new topic on the [forum] in the "Feature" category. This will help you to: + +- Determine if the capability already exists +- Measure interest +- Refine the concept + +If there is sufficient interest, [create a proposal]. Do not submit a pull request until the project lead accepts the proposal. For a complete guide to contributing to Hugo, see the [Contribution Guide](CONTRIBUTING.md). -We welcome contributions to Hugo of any kind including documentation, themes, -organization, tutorials, blog posts, bug reports, issues, feature requests, -feature implementations, pull requests, answering questions on the forum, -helping to manage issues, etc. - -The Hugo community and maintainers are [very active](https://github.com/gohugoio/hugo/pulse/monthly) and helpful, and the project benefits greatly from this activity. - -### Asking Support Questions - -We have an active [discussion forum](https://discourse.gohugo.io) where users and developers can ask questions. -Please don't use the GitHub issue tracker to ask questions. - -### Reporting Issues - -If you believe you have found a defect in Hugo or its documentation, use -the GitHub issue tracker to report the problem to the Hugo maintainers. -If you're not sure if it's a bug or not, start by asking in the [discussion forum](https://discourse.gohugo.io). -When reporting the issue, please provide the version of Hugo in use (`hugo version`). - -### Submitting Patches - -The Hugo project welcomes all contributors and contributions regardless of skill or experience level. -If you are interested in helping with the project, we will help you with your contribution. -Hugo is a very active project with many contributions happening daily. - -Because we want to create the best possible product for our users and the best contribution experience for our developers, -we have a set of guidelines which ensure that all contributions are acceptable. -The guidelines are not intended as a filter or barrier to participation. -If you are unfamiliar with the contribution process, the Hugo team will help you and teach you how to bring your contribution in accordance with the guidelines. - -For a complete guide to contributing code to Hugo, see the [Contribution Guide](CONTRIBUTING.md). - -[](https://github.com/igrigorik/ga-beacon) - -[Go]: https://golang.org/ -[Hugo Documentation]: https://gohugo.io/overview/introduction/ - ## Dependencies -Hugo stands on the shoulder of many great open source libraries, in lexical order: +Hugo stands on the shoulders of great open source libraries. Run `hugo env --logLevel info` to display a list of dependencies. - | Dependency | License | - | :------------- | :------------- | - | [github.com/BurntSushi/locker](https://github.com/BurntSushi/locker) | The Unlicense | - | [github.com/BurntSushi/toml](https://github.com/BurntSushi/toml) | MIT License | - | [github.com/PuerkitoBio/purell](https://github.com/PuerkitoBio/purell) | BSD 3-Clause "New" or "Revised" License | - | [github.com/PuerkitoBio/urlesc](https://github.com/PuerkitoBio/urlesc) | BSD 3-Clause "New" or "Revised" License | - | [github.com/alecthomas/chroma](https://github.com/alecthomas/chroma) | MIT License | - | [github.com/bep/debounce](https://github.com/bep/debounce) | MIT License | - | [github.com/bep/gitmap](https://github.com/bep/gitmap) | MIT License | - | [github.com/bep/go-tocss](https://github.com/bep/go-tocss) | MIT License | - | [github.com/chaseadamsio/goorgeous](https://github.com/chaseadamsio/goorgeous) | MIT License | - | [github.com/cpuguy83/go-md2man](https://github.com/cpuguy83/go-md2man) | MIT License | - | [github.com/danwakefield/fnmatch](https://github.com/danwakefield/fnmatch) | BSD 2-Clause "Simplified" License | - | [github.com/disintegration/imaging](https://github.com/disintegration/imaging) | MIT License | - | [github.com/dlclark/regexp2](https://github.com/dlclark/regexp2) | MIT License | - | [github.com/eknkc/amber](https://github.com/eknkc/amber) | MIT License | - | [github.com/fsnotify/fsnotify](https://github.com/fsnotify/fsnotify) | BSD 3-Clause "New" or "Revised" License | - | [github.com/gobwas/glob](https://github.com/gobwas/glob) | MIT License | - | [github.com/gorilla/websocket](https://github.com/gorilla/websocket) | BSD 2-Clause "Simplified" License | - | [github.com/hashicorp/go-immutable-radix](https://github.com/hashicorp/go-immutable-radix) | Mozilla Public License 2.0 | - | [github.com/hashicorp/golang-lru](https://github.com/hashicorp/golang-lru) | Mozilla Public License 2.0 | - | [github.com/hashicorp/hcl](https://github.com/hashicorp/hcl) | Mozilla Public License 2.0 | - | [github.com/jdkato/prose](https://github.com/jdkato/prose) | MIT License | - | [github.com/kyokomi/emoji](https://github.com/kyokomi/emoji) | MIT License | - | [github.com/magiconair/properties](https://github.com/magiconair/properties) | BSD 2-Clause "Simplified" License | - | [github.com/markbates/inflect](https://github.com/markbates/inflect) | MIT License | - | [github.com/mattn/go-isatty](https://github.com/mattn/go-isatty) | MIT License | - | [github.com/mattn/go-runewidth](https://github.com/mattn/go-runewidth) | MIT License | - | [github.com/miekg/mmark](https://github.com/miekg/mmark) | Simplified BSD License | - | [github.com/mitchellh/hashstructure](https://github.com/mitchellh/hashstructure) | MIT License | - | [github.com/mitchellh/mapstructure](https://github.com/mitchellh/mapstructure) | MIT License | - | [github.com/muesli/smartcrop](https://github.com/muesli/smartcrop) | MIT License | - | [github.com/nicksnyder/go-i18n](https://github.com/nicksnyder/go-i18n) | MIT License | - | [github.com/olekukonko/tablewriter](https://github.com/olekukonko/tablewriter) | MIT License | - | [github.com/pelletier/go-toml](https://github.com/pelletier/go-toml) | MIT License | - | [github.com/pkg/errors](https://github.com/pkg/errors) | BSD 2-Clause "Simplified" License | - | [github.com/russross/blackfriday](https://github.com/russross/blackfriday) | Simplified BSD License | - | [github.com/shurcooL/sanitized_anchor_name](https://github.com/shurcooL/sanitized_anchor_name) | MIT License | - | [github.com/spf13/afero](https://github.com/spf13/afero) | Apache License 2.0 | - | [github.com/spf13/cast](https://github.com/spf13/cast) | MIT License | - | [github.com/spf13/cobra](https://github.com/spf13/cobra) | Apache License 2.0 | - | [github.com/spf13/fsync](https://github.com/spf13/fsync) | MIT License | - | [github.com/spf13/jwalterweatherman](https://github.com/spf13/jwalterweatherman) | MIT License | - | [github.com/spf13/nitro](https://github.com/spf13/nitro) | Apache License 2.0 | - | [github.com/spf13/pflag](https://github.com/spf13/pflag) | BSD 3-Clause "New" or "Revised" License | - | [github.com/spf13/viper](https://github.com/spf13/viper) | MIT License | - | [github.com/tdewolff/minify](https://github.com/tdewolff/minify) | MIT License | - | [github.com/tdewolff/parse](https://github.com/tdewolff/parse) | MIT License | - | [github.com/wellington/go-libsass](https://github.com/wellington/go-libsass) | Apache License 2.0 | - | [github.com/yosssi/ace](https://github.com/yosssi/ace) | MIT License | - | [golang.org/x/image](https://golang.org/x/image) | BSD 3-Clause "New" or "Revised" License | - | [golang.org/x/net](https://golang.org/x/net) | BSD 3-Clause "New" or "Revised" License | - | [golang.org/x/sync](https://golang.org/x/sync) | BSD 3-Clause "New" or "Revised" License | - | [golang.org/x/sys](https://golang.org/x/sys) | BSD 3-Clause "New" or "Revised" License | - | [golang.org/x/text](https://golang.org/x/text) | BSD 3-Clause "New" or "Revised" License - | [gopkg.in/yaml.v2](https://gopkg.in/yaml.v2) | Apache License 2.0 | +
{{ .Version }}
- Reload Page -Copyright {{ now.Year }}. All rights reserved.
diff --git a/create/skeletons/theme/layouts/_partials/head.html b/create/skeletons/theme/layouts/_partials/head.html new file mode 100644 index 000000000..02c224018 --- /dev/null +++ b/create/skeletons/theme/layouts/_partials/head.html @@ -0,0 +1,5 @@ + + +{{ debug.Dump $taxonomyObject }}+``` + +Although the [`Alphabetical`] and [`ByCount`] methods provide a better data structure for ranging through the taxonomy, you can render the weighted pages by term directly from the `Taxonomy` object: + +```go-html-template +{{ range $term, $weightedPages := $taxonomyObject }} +
Related content:
+{{ .ShortBio }}
-Author: {{ .Params.author }}
+ +
+ ISBN: {{ .Params.isbn }}
+ Rating: {{ .Params.rating }}
+ Review date: {{ .Date | time.Format ":date_long" }}
+
Tags:
+{{ . }} | + {{ end }} +
---|
{{ . }} | + {{ end }} +
+ {{ .Inner | htmlEscape | safeHTML }} ++{{ .Page.Store.Set "hasMermaid" true }} +``` + +Then include this snippet at the _bottom_ of your base template, before the closing `body` tag: + +```go-html-template {file="layouts/_default/baseof.html" copy=true} +{{ if .Store.Get "hasMermaid" }} + +{{ end }} +``` + +With that you can use the `mermaid` language in Markdown code blocks: + +````text {copy=true} +```mermaid +sequenceDiagram + participant Alice + participant Bob + Alice->>John: Hello John, how are you? + loop Healthcheck + John->>John: Fight against hypochondria + end + Note right of John: Rational thoughts
Tags
+++``` + +In most cases, place the attribute list beneath the markup element. For headings and fenced code blocks, place the attribute list on the right. + +Element|Position of attribute list +:--|:-- +blockquote | bottom +fenced code block | right +heading | right +horizontal rule | bottom +image | bottom +list | bottom +paragraph | bottom +table | bottom + +For example: + +````text +## Section 1 {class=foo} + +```bash {class=foo linenos=inline} +declare a=1 +echo "${a}" +``` + +This is a paragraph. +{class=foo} +```` + +As shown above, the attribute list for fenced code blocks is not limited to HTML attributes. You can also configure syntax highlighting by passing one or more of [these options](/functions/transform/highlight/#options). diff --git a/docs/content/en/content-management/mathematics.md b/docs/content/en/content-management/mathematics.md new file mode 100644 index 000000000..e0c8ba4d0 --- /dev/null +++ b/docs/content/en/content-management/mathematics.md @@ -0,0 +1,238 @@ +--- +title: Mathematics in Markdown +linkTitle: Mathematics +description: Include mathematical equations and expressions in Markdown using LaTeX markup. +categories: [] +keywords: [] +--- + +{{< new-in 0.122.0 />}} + +## Overview + +Mathematical equations and expressions written in [LaTeX] are common in academic and scientific publications. Your browser typically renders this mathematical markup using an open-source JavaScript display engine such as [MathJax] or [KaTeX]. + +For example, with this LaTeX markup: + +```text +\[ +\begin{aligned} +KL(\hat{y} || y) &= \sum_{c=1}^{M}\hat{y}_c \log{\frac{\hat{y}_c}{y_c}} \\ +JS(\hat{y} || y) &= \frac{1}{2}(KL(y||\frac{y+\hat{y}}{2}) + KL(\hat{y}||\frac{y+\hat{y}}{2})) +\end{aligned} +\] +``` + +The MathJax display engine renders this: + +\[ +\begin{aligned} +KL(\hat{y} || y) &= \sum_{c=1}^{M}\hat{y}_c \log{\frac{\hat{y}_c}{y_c}} \\ +JS(\hat{y} || y) &= \frac{1}{2}(KL(y||\frac{y+\hat{y}}{2}) + KL(\hat{y}||\frac{y+\hat{y}}{2})) +\end{aligned} +\] + +Equations and expressions can be displayed inline with other text, or as standalone blocks. Block presentation is also known as "display" mode. + +Whether an equation or expression appears inline, or as a block, depends on the delimiters that surround the mathematical markup. Delimiters are defined in pairs, where each pair consists of an opening and closing delimiter. The opening and closing delimiters may be the same, or different. + +> [!note] +> You can configure Hugo to render mathematical markup on the client side using the MathJax or KaTeX display engine, or you can render the markup with the [`transform.ToMath`] function while building your site. +> +> The first approach is described below. + +## Setup + +Follow these instructions to include mathematical equations and expressions in your Markdown using LaTeX markup. + +### Step 1 + +Enable and configure the Goldmark [passthrough extension] in your site configuration. The passthrough extension preserves raw Markdown within delimited snippets of text, including the delimiters themselves. + +{{< code-toggle file=hugo copy=true >}} +[markup.goldmark.extensions.passthrough] +enable = true + +[markup.goldmark.extensions.passthrough.delimiters] +block = [['\[', '\]'], ['$$', '$$']] +inline = [['\(', '\)']] + +[params] +math = true +{{< /code-toggle >}} + +The configuration above enables mathematical rendering on every page unless you set the `math` parameter to `false` in front matter. To enable mathematical rendering as needed, set the `math` parameter to `false` in your site configuration, and set the `math` parameter to `true` in front matter. Use this parameter in your base template as shown in [Step 3]. + +> [!note] +> The configuration above precludes the use of the `$...$` delimiter pair for inline equations. Although you can add this delimiter pair to the configuration and JavaScript, you will need to double-escape the `$` symbol when used outside of math contexts to avoid unintended formatting. +> +> See the [inline delimiters](#inline-delimiters) section for details. + +To disable passthrough of inline snippets, omit the `inline` key from the configuration: + +{{< code-toggle file=hugo >}} +[markup.goldmark.extensions.passthrough.delimiters] +block = [['\[', '\]'], ['$$', '$$']] +{{< /code-toggle >}} + +You can define your own opening and closing delimiters, provided they match the delimiters that you set in [Step 2]. + +{{< code-toggle file=hugo >}} +[markup.goldmark.extensions.passthrough.delimiters] +block = [['@@', '@@']] +inline = [['@', '@']] +{{< /code-toggle >}} + +### Step 2 + +Create a partial template to load MathJax or KaTeX. The example below loads MathJax, or you can use KaTeX as described in the [engines](#engines) section. + +```go-html-template {file="layouts/partials/math.html" copy=true} + + +``` + +The delimiters above must match the delimiters in your site configuration. + +### Step 3 + +Conditionally call the partial template from the base template. + +```go-html-template {file="layouts/_default/baseof.html"} + + ... + {{ if .Param "math" }} + {{ partialCached "math.html" . }} + {{ end }} + ... + +``` + +The example above loads the partial template if you have set the `math` parameter in front matter to `true`. If you have not set the `math` parameter in front matter, the conditional statement falls back to the `math` parameter in your site configuration. + +### Step 4 + +Include mathematical equations and expressions in Markdown using LaTeX markup. + +```text {file="content/math-examples.md" copy=true} +This is an inline \(a^*=x-b^*\) equation. + +These are block equations: + +\[a^*=x-b^*\] + +\[ a^*=x-b^* \] + +\[ +a^*=x-b^* +\] + +These are also block equations: + +$$a^*=x-b^*$$ + +$$ a^*=x-b^* $$ + +$$ +a^*=x-b^* +$$ +``` + +If you set the `math` parameter to `false` in your site configuration, you must set the `math` parameter to `true` in front matter. For example: + +{{< code-toggle file=content/math-examples.md fm=true >}} +title = 'Math examples' +date = 2024-01-24T18:09:49-08:00 +[params] +math = true +{{< /code-toggle >}} + +## Inline delimiters + +The configuration, JavaScript, and examples above use the `\(...\)` delimiter pair for inline equations. The `$...$` delimiter pair is a common alternative, but using it may result in unintended formatting if you use the `$` symbol outside of math contexts. + +If you add the `$...$` delimiter pair to your configuration and JavaScript, you must double-escape the `$` when outside of math contexts, regardless of whether mathematical rendering is enabled on the page. For example: + +```text +A \\$5 bill _saved_ is a \\$5 bill _earned_. +``` + +> [!note] +> If you use the `$...$` delimiter pair for inline equations, and occasionally use the `$` symbol outside of math contexts, you must use MathJax instead of KaTeX to avoid unintended formatting caused by [this KaTeX limitation](https://github.com/KaTeX/KaTeX/issues/437). + +## Engines + +MathJax and KaTeX are open-source JavaScript display engines. Both engines are fast, but at the time of this writing MathJax v3.2.2 is slightly faster than KaTeX v0.16.11. + +> [!note] +> If you use the `$...$` delimiter pair for inline equations, and occasionally use the `$` symbol outside of math contexts, you must use MathJax instead of KaTeX to avoid unintended formatting caused by [this KaTeX limitation](https://github.com/KaTeX/KaTeX/issues/437). +> +>See the [inline delimiters](#inline-delimiters) section for details. + +To use KaTeX instead of MathJax, replace the partial template from [Step 2] with this: + +```go-html-template {file="layouts/partials/math.html" copy=true} + + + + +``` + +The delimiters above must match the delimiters in your site configuration. + +## Chemistry + +Both MathJax and KaTeX provide support for chemical equations. For example: + +```text +$$C_p[\ce{H2O(l)}] = \pu{75.3 J // mol K}$$ +``` + +$$C_p[\ce{H2O(l)}] = \pu{75.3 J // mol K}$$ + +As shown in [Step 2] above, MathJax supports chemical equations without additional configuration. To add chemistry support to KaTeX, enable the mhchem extension as described in the KaTeX [documentation](https://katex.org/docs/libs). + +[`transform.ToMath`]: /functions/transform/tomath/ +[KaTeX]: https://katex.org/ +[LaTeX]: https://www.latex-project.org/ +[MathJax]: https://www.mathjax.org/ +[passthrough extension]: /configuration/markup/#passthrough +[Step 2]: #step-2 +[Step 3]: #step-3 diff --git a/docs/content/en/content-management/menus.md b/docs/content/en/content-management/menus.md index bc48c82e7..6d01173dc 100644 --- a/docs/content/en/content-management/menus.md +++ b/docs/content/en/content-management/menus.md @@ -1,123 +1,97 @@ --- title: Menus -linktitle: Menus -description: Hugo has a simple yet powerful menu system. -date: 2017-02-01 -publishdate: 2017-02-01 -lastmod: 2017-03-31 -categories: [content management] -keywords: [menus] -draft: false -menu: - docs: - parent: "content-management" - weight: 120 -weight: 120 #rem +description: Create menus by defining entries, localizing each entry, and rendering the resulting data structure. +categories: [] +keywords: [] aliases: [/extras/menus/] -toc: true --- -{{% note "Lazy Blogger"%}} -If all you want is a simple menu for your sections, see the ["Section Menu for Lazy Bloggers" in Menu Templates](/templates/menu-templates/#section-menu-for-lazy-bloggers). -{{% /note %}} +## Overview -You can do this: +To create a menu for your site: -* Place content in one or many menus -* Handle nested menus with unlimited depth -* Create menu entries without being attached to any content -* Distinguish active element (and active branch) +1. Define the menu entries +1. [Localize](multilingual/#menus) each entry +1. Render the menu with a [template] -## What is a Menu in Hugo? +Create multiple menus, either flat or nested. For example, create a main menu for the header, and a separate menu for the footer. -A **menu** is a named array of menu entries accessible by name via the [`.Site.Menus` site variable][sitevars]. For example, you can access your site's `main` menu via `.Site.Menus.main`. +There are three ways to define menu entries: -{{% note "Menus on Multilingual Sites" %}} -If you make use of the [multilingual feature](/content-management/multilingual/), you can define language-independent menus. -{{% /note %}} +1. Automatically +1. In front matter +1. In site configuration -See the [Menu Entry Properties][me-props] for all the variables and functions related to a menu entry. +> [!note] +> Although you can use these methods in combination when defining a menu, the menu will be easier to conceptualize and maintain if you use one method throughout the site. -## Add content to menus +## Define automatically -Hugo allows you to add content to a menu via the content's [front matter](/content-management/front-matter/). +To automatically define a menu entry for each top-level [section](g) of your site, enable the section pages menu in your site configuration. -### Simple - -If all you need to do is add an entry to a menu, the simple form works well. - -#### A Single Menu - -``` ---- -menu: "main" ---- -``` - -#### Multiple Menus - -``` ---- -menu: ["main", "footer"] ---- -``` - -#### Advanced - - -``` ---- -menu: - docs: - parent: 'extras' - weight: 20 ---- -``` - -## Add Non-content Entries to a Menu - -You can also add entries to menus that aren’t attached to a piece of content. This takes place in your Hugo project's [`config` file][config]. - -Here’s an example snippet pulled from a configuration file: - -{{< code-toggle file="config" >}} -[[menu.main]] - name = "about hugo" - pre = "" - weight = -110 - identifier = "about" - url = "/about/" -[[menu.main]] - name = "getting started" - pre = "" - post = "New!" - weight = -100 - url = "/getting-started/" +{{< code-toggle file=hugo >}} +sectionPagesMenu = "main" {{< /code-toggle >}} -{{% note %}} -The URLs must be relative to the context root. If the `baseURL` is `https://example.com/mysite/`, then the URLs in the menu must not include the context root `mysite`. Using an absolute URL will override the baseURL. If the value used for `URL` in the above example is `https://subdomain.example.com/`, the output will be `https://subdomain.example.com`. -{{% /note %}} +This creates a menu structure that you can access with `site.Menus.main` in your templates. See [menu templates] for details. -## Nesting +## Define in front matter -All nesting of content is done via the `parent` field. +To add a page to the "main" menu: -The parent of an entry should be the identifier of another entry. The identifier should be unique (within a menu). +{{< code-toggle file=content/about.md fm=true >}} +title = 'About' +menus = 'main' +{{< /code-toggle >}} -The following order is used to determine an Identifier: +Access the entry with `site.Menus.main` in your templates. See [menu templates] for details. -`.Name > .LinkTitle > .Title` +To add a page to the "main" and "footer" menus: -This means that `.Title` will be used unless `.LinkTitle` is present, etc. In practice, `.Name` and `.Identifier` are only used to structure relationships and therefore never displayed. +{{< code-toggle file=content/contact.md fm=true >}} +title = 'Contact' +menus = ['main','footer'] +{{< /code-toggle >}} -In this example, the top level of the menu is defined in your [site `config` file][config]). All content entries are attached to one of these entries via the `.Parent` field. +Access the entry with `site.Menus.main` and `site.Menus.footer` in your templates. See [menu templates] for details. -## Render Menus +> [!note] +> The configuration key in the examples above is `menus`. The `menu` (singular) configuration key is an alias for `menus`. -See [Menu Templates](/templates/menu-templates/) for information on how to render your site menus within your templates. +### Properties -[config]: /getting-started/configuration/ -[multilingual]: /content-management/multilingual/ -[sitevars]: /variables/ -[me-props]: /variables/menus/ +Use these properties when defining menu entries in front matter: + +{{% include "/_common/menu-entry-properties.md" %}} + +### Example + +This front matter menu entry demonstrates some of the available properties: + +{{< code-toggle file=content/products/software.md fm=true >}} +title = 'Software' +[menus.main] +parent = 'Products' +weight = 20 +pre = '' +[menus.main.params] +class = 'center' +{{< /code-toggle >}} + +Access the entry with `site.Menus.main` in your templates. See [menu templates] for details. + +## Define in site configuration + +See [configure menus](/configuration/menus/). + +## Localize + +Hugo provides two methods to localize your menu entries. See [multilingual]. + +## Render + +See [menu templates]. + +[menu templates]: /templates/menu/ +[multilingual]: /content-management/multilingual/#menus +[template]: /templates/menu/ diff --git a/docs/content/en/content-management/multilingual.md b/docs/content/en/content-management/multilingual.md index c72cb50ce..d419f4381 100644 --- a/docs/content/en/content-management/multilingual.md +++ b/docs/content/en/content-management/multilingual.md @@ -1,462 +1,429 @@ --- -title: Multilingual Mode -linktitle: Multilingual and i18n -description: Hugo supports the creation of websites with multiple languages side by side. -date: 2017-01-10 -publishdate: 2017-01-10 -lastmod: 2017-01-10 -categories: [content management] -keywords: [multilingual,i18n, internationalization] -menu: - docs: - parent: "content-management" - weight: 150 -weight: 150 #rem -draft: false +title: Multilingual mode +linkTitle: Multilingual +description: Localize your project for each language and region, including translations, images, dates, currencies, numbers, percentages, and collation sequence. Hugo's multilingual framework supports single-host and multihost configurations. +categories: [] +keywords: [] aliases: [/content/multilingual/,/tutorials/create-a-multilingual-site/] -toc: true --- -You should define the available languages in a `languages` section in your site configuration. +## Configuration -> Also See [Hugo Multilingual Part 1: Content translation](https://regisphilibert.com/blog/2018/08/hugo-multilingual-part-1-managing-content-translation/) +See [configure languages](/configuration/languages/). -## Configure Languages +## Translate your content -The following is an example of a site configuration for a multilingual Hugo project: +There are two ways to manage your content translations. Both ensure each page is assigned a language and is linked to its counterpart translations. -{{< code-toggle file="config" >}} -DefaultContentLanguage = "en" -copyright = "Everything is mine" - -[params] -[params.navigation] -help = "Help" - -[languages] -[languages.en] -title = "My blog" -weight = 1 -[languages.en.params] -linkedin = "https://linkedin.com/whoever" - -[languages.fr] -title = "Mon blogue" -weight = 2 -[languages.fr.params] -linkedin = "https://linkedin.com/fr/whoever" -[languages.fr.params.navigation] -help = "Aide" -{{< /code-toggle >}} - -Anything not defined in a `[languages]` block will fall back to the global value for that key (e.g., `copyright` for the English [`en`] language). This also works for `params`, as demonstrated witgh `help` above: You will get the value `Aide` in French and `Help` in all the languages without this parameter set. - -With the configuration above, all content, sitemap, RSS feeds, paginations, -and taxonomy pages will be rendered below `/` in English (your default content language) and then below `/fr` in French. - -When working with front matter `Params` in [single page templates][singles], omit the `params` in the key for the translation. - -`defaultContentLanguage` sets the project's default language. If not set, the default language will be `en`. - -If the default language needs to be rendererd below its own language code (`/en`) like the others, set `defaultContentLanguageInSubdir: true`. - -Only the obvious non-global options can be overridden per language. Examples of global options are `baseURL`, `buildDrafts`, etc. - -### Disable a Language - -You can disable one or more languages. This can be useful when working on a new translation. - -```toml -disableLanguages = ["fr", "ja"] -``` - -Note that you cannot disable the default content language. - -We kept this as a standalone setting to make it easier to set via [OS environment](/getting-started/configuration/#configure-with-environment-variables): - -```bash -HUGO_DISABLELANGUAGES="fr ja" hugo -``` -If you have already a list of disabled languages in `config.toml`, you can enable them in development like this: - -```bash -HUGO_DISABLELANGUAGES=" " hugo server -``` - - -### Configure Multilingual Multihost - -From **Hugo 0.31** we support multiple languages in a multihost configuration. See [this issue](https://github.com/gohugoio/hugo/issues/4027) for details. - -This means that you can now configure a `baseURL` per `language`: - - -> If a `baseURL` is set on the `language` level, then all languages must have one and they must all be different. - -Example: - -{{< code-toggle file="config" >}} -[languages] -[languages.fr] -baseURL = "https://example.fr" -languageName = "Français" -weight = 1 -title = "En Français" - -[languages.en] -baseURL = "https://example.com" -languageName = "English" -weight = 2 -title = "In English" -{{ code-toggle >}} - -With the above, the two sites will be generated into `public` with their own root: - -```bash -public -├── en -└── no -``` - -**All URLs (i.e `.Permalink` etc.) will be generated from that root. So the English home page above will have its `.Permalink` set to `https://example.com/`.** - -When you run `hugo server` we will start multiple HTTP servers. You will typlically see something like this in the console: - -```bash -Web Server is available at 127.0.0.1:1313 (bind address 127.0.0.1) -Web Server is available at 127.0.0.1:1314 (bind address 127.0.0.1) -Press Ctrl+C to stop -``` - -Live reload and `--navigateToChanged` between the servers work as expected. - -### Taxonomies and Blackfriday - -Taxonomies and [Blackfriday configuration][config] can also be set per language: - - -{{< code-toggle file="config" >}} -[Taxonomies] -tag = "tags" - -[blackfriday] -angledQuotes = true -hrefTargetBlank = true - -[languages] -[languages.en] -weight = 1 -title = "English" -[languages.en.blackfriday] -angledQuotes = false - -[languages.fr] -weight = 2 -title = "Français" -[languages.fr.Taxonomies] -plaque = "plaques" -{{ code-toggle >}} - -## Translate Your Content - -There are two ways to manage your content translation, both ensures each page is assigned a language and linked to its translations. - -### Translation by filename +### Translation by file name Considering the following example: 1. `/content/about.en.md` -2. `/content/about.fr.md` +1. `/content/about.fr.md` -The first file is assigned the english language and linked to the second. -The second file is assigned the french language and linked to the first. +The first file is assigned the English language and is linked to the second. +The second file is assigned the French language and is linked to the first. -Their language is __assigned__ according to the language code added as __suffix to the filename__. +Their language is __assigned__ according to the language code added as a __suffix to the file name__. -By having the same **path and base filename**, the content pieces are __linked__ together as translated pages. -{{< note >}} +By having the same **path and base file name**, the content pieces are __linked__ together as translated pages. -If a file is missing any language code, it will be assigned the default language. +> [!note] +> If a file has no language code, it will be assigned the default language. -{{ note >}} ### Translation by content directory -This system uses different content directories for each of the languages. Each language's content directory is set using the `contentDir` param. - -{{< code-toggle file="config" >}} +This system uses different content directories for each of the languages. Each language's `content` directory is set using the `contentDir` parameter. +{{< code-toggle file=hugo >}} languages: en: weight: 10 languageName: "English" contentDir: "content/english" - nn: + fr: weight: 20 languageName: "Français" contentDir: "content/french" - {{< /code-toggle >}} -The value of `contentDir` can be any valid path, even absolute path references. The only restriction is that the content directories cannot overlap. +The value of `contentDir` can be any valid path -- even absolute path references. The only restriction is that the content directories cannot overlap. -Considering the following example in conjunction with the configuration above: +Considering the following example in conjunction with the configuration above: 1. `/content/english/about.md` -2. `/content/french/about.md` +1. `/content/french/about.md` -The first file is assigned the english language and is linked to the second. -This is a blockquote.
+
Books:
+Related content:
+Hello World!
{{* /myshortcode */>}} +```html +Today is Jan 30, 2025.
+Today is Thursday, January 30, 2025
``` -### Nested Shortcodes +Inline shortcodes process their inner content within the same context as regular shortcode templates, allowing you to use any available [shortcode method]. -You can call shortcodes within other shortcodes by creating your own templates that leverage the `.Parent` variable. `.Parent` allows you to check the context in which the shortcode is being called. See [Shortcode templates][sctemps]. +> [!note] +> You cannot [nest](#nesting) inline shortcodes. -## Use Hugo's Built-in Shortcodes +Learn more about creating shortcodes in the [shortcode templates] section. -Hugo ships with a set of predefined shortcodes that represent very common usage. These shortcodes are provided for author convenience and to keep your markdown content clean. +## Calling -### `figure` +Shortcode calls involve three syntactical elements: tags, arguments, and notation. -`figure` is an extension of the image syntax in markdown, which does not provide a shorthand for the more semantic [HTML5 `