Skip to content

Framework guides: add Hugo SSG #2269

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions next.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,11 @@ const nextConfig = {
destination: "/docs/installation/framework-guides/symfony",
permanent: false,
},
{
source: "/docs/guides/hugo",
destination: "/docs/installation/framework-guides/hugo",
permanent: false,
},
{
source: "/docs/guides/meteor",
destination: "/docs/installation/framework-guides/meteor",
Expand Down
159 changes: 159 additions & 0 deletions src/app/(docs)/docs/installation/framework-guides/hugo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
import { css, html, Page, shell, Step, Tile, yaml } from "./utils";
import Logo from "@/docs/img/guides/hugo.react.svg";

export let tile: Tile = {
title: "Hugo",
description: "Static site generator written in Go.",
Logo,
};

export let page: Page = {
title: "Install Tailwind CSS with Hugo",
description: "Setting up Tailwind CSS in a Hugo project.",
};

export let steps: Step[] = [
{
title: "Create your project",
body: (
<p>
Start by creating a new Hugo project if you don't have one set up already.
</p>
),
code: {
name: "Terminal",
lang: "shell",
code: shell`
hugo new site --format yaml my-site
cd my-site
`,
},
},
{
title: "Install Tailwind CSS",
body: (
<p>
Install the Tailwind CSS CLI v4.1 or later.
</p>
),

code: {
name: "Terminal",
lang: "shell",
code: shell`
npm install --save-dev tailwindcss @tailwindcss/cli
`,
},
},
{
title: "Configure build parameters",
body: (
<p>
Add these build parameters to your site configuration.
</p>
),
code: {
name: "hugo.yaml",
lang: "yaml",
code: yaml`
build:
buildStats:
enable: true
cachebusters:
- source: assets/notwatching/hugo_stats\.json
target: css
- source: (postcss|tailwind)\.config\.js
target: css
module:
mounts:
- source: assets
target: assets
- disableWatch: true
source: hugo_stats.json
target: assets/notwatching/hugo_stats.json
`,
},
},
{
title: "Create CSS entry file",
body: <p>If you want Tailwind CSS to ignore your `hugo_stats.json`, list it in your `.gitignore` file.</p>,
code: {
name: "assets/css/main.css",
lang: "css",
code: css`
@import "tailwindcss";
@source "hugo_stats.json";
`,
},
},
{
title: "Create partial template",
body: <p>Create a partial template to process the CSS with the Tailwind CSS CLI.</p>,
code: {
name: "layouts/_partials/css.html",
lang: "html",
code: html`
{{ with (templates.Defer (dict "key" "global")) }}
{{ with resources.Get "css/main.css" }}
{{ $opts := dict "minify" (not hugo.IsDevelopment) }}
{{ with . | css.TailwindCSS $opts }}
{{ if hugo.IsDevelopment }}
<link rel="stylesheet" href="{{ .RelPermalink }}">
{{ else }}
{{ with . | fingerprint }}
<link rel="stylesheet" href="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous">
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
`,
},
},
{
title: "Start your build process",
body: (
<p>
Start the preview of your site.
</p>
),
code: {
name: "Terminal",
lang: "shell",
code: shell`
hugo server -M
`,
},
},
{
title: "Start using Tailwind in your Hugo project",
body: (
<p>
Add the partial template to the <code>{"<head>"}</code> of your base template and start using Tailwind’s utility classes to style the
content of your templates and pages.
</p>
),
code: {
name: "layouts/all.html",
lang: "html",
code: html`
<!doctype html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- [!code highlight:2] -->
{{ partialCached "css.html" . }}
</head>
<body>
<!-- [!code highlight:4] -->
<h1 class="text-3xl font-bold underline">
<!-- prettier-ignore -->
Hello world!
</h1>
</body>
</html>
`,
},
},
];
1 change: 1 addition & 0 deletions src/app/(docs)/docs/installation/framework-guides/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const guides: Guide[] = await create({
astro: () => import("./astro"),
qwik: () => import("./qwik"),
rspack: () => import("./rspack"),
hugo: () => import("./hugo"),
});

async function create(list: Record<string, () => Promise<any>>): Promise<Guide[]> {
Expand Down
1 change: 1 addition & 0 deletions src/app/(docs)/docs/installation/framework-guides/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const html = dedent;
export const astro = dedent;
export const twig = dedent;
export const elixir = dedent;
export const yaml = dedent;
export const handlebars = dedent;

export interface LogoComponent {
Expand Down
1 change: 1 addition & 0 deletions src/components/code-example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ const highlighter = await createHighlighter({
"tsx",
"twig",
"vue",
"yaml",
"md",
],
});
1 change: 1 addition & 0 deletions src/components/highlight.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export const highlighter = await createHighlighter({
"tsx",
"twig",
"vue",
"yaml",
"md",
],
});
14 changes: 14 additions & 0 deletions src/docs/img/guides/hugo.react.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.