<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Web on kenji.blog</title><link>http://kenji.blog/de/categories/web/</link><description>Recent content in Web on kenji.blog</description><generator>Hugo -- gohugo.io</generator><language>de</language><copyright>kenjinote</copyright><lastBuildDate>Sun, 13 Sep 2026 03:00:00 +0900</lastBuildDate><atom:link href="http://kenji.blog/de/categories/web/index.xml" rel="self" type="application/rss+xml"/><item><title>Hugo Theme-Anpassung: Wie man Tailwind CSS einführt</title><link>http://kenji.blog/de/p/hugo-tailwind-css-customization-guide/</link><pubDate>Sun, 13 Sep 2026 03:00:00 +0900</pubDate><guid>http://kenji.blog/de/p/hugo-tailwind-css-customization-guide/</guid><description>&lt;img src="http://kenji.blog/p/hugo-tailwind-css-customization-guide/img/eyecatch.jpg" alt="Featured image of post Hugo Theme-Anpassung: Wie man Tailwind CSS einführt" />&lt;h1 id="einführung-die-starke-synergie-zwischen-dem-static-site-generator-hugo-und-tailwind-css">Einführung: Die starke Synergie zwischen dem Static Site Generator Hugo und Tailwind CSS
&lt;/h1>&lt;p>In der modernen Web-Frontend-Entwicklung ist die Vereinbarkeit von Leistung und Entwicklererfahrung (DX: Developer Experience) eines der wichtigsten Anliegen in jedem Projekt. Die Kombination von &lt;strong>Hugo&lt;/strong>, das unter den Static Site Generatoren (SSG) zu den schnellsten der Welt gehört, mit &lt;strong>Tailwind CSS&lt;/strong>, das das innovative Paradigma &amp;ldquo;Utility-First&amp;rdquo; eingeführt hat, kann als ultimative Lösung für dieses Problem angesehen werden.&lt;/p>
&lt;p>Hugo ist in Go geschrieben und bietet eine unglaubliche Leistung, mit der Builds selbst für Websites mit Tausenden von Seiten in nur wenigen Sekunden oder Millisekunden abgeschlossen werden. Andererseits ermöglicht Tailwind CSS das direkte Schreiben unzähliger vordefinierter Utility-Klassen (z. B. &lt;code>flex&lt;/code>, &lt;code>text-center&lt;/code>, &lt;code>mt-4&lt;/code>) in HTML, wodurch der Kontextwechsel zwischen CSS- und HTML-Dateien entfällt und Design-Iterationen beschleunigt werden.&lt;/p>
&lt;p>In diesem Artikel werden wir die Schritte zur Integration von Tailwind CSS in ein Hugo-Theme und zum Aufbau einer fortschrittlichen Asset-Pipeline (Hugo Pipes) mit PostCSS im Detail erläutern – von den Grundlagen der Architektur bis hin zu mathematischen Leistungsoptimierungen.&lt;/p>
&lt;hr>
&lt;h2 id="1-die-entwicklung-von-utility-first-css-und-komponentenbasiertem-design">1. Die Entwicklung von Utility-First CSS und komponentenbasiertem Design
&lt;/h2>&lt;p>Bevor wir zu den Schritten für die Integration von Tailwind CSS übergehen, ist es sehr hilfreich, die Geschichte und Entwicklung der CSS-Design-Philosophie zu verstehen, um zu begreifen, warum wir Tailwind CSS verwenden sollten.&lt;/p>
&lt;h3 id="die-grenzen-des-traditionellen-css-designs-bem-und-oocss">Die Grenzen des traditionellen CSS-Designs (BEM und OOCSS)
&lt;/h3>&lt;p>In der Vergangenheit galt es in der Webentwicklung als Best Practice, semantische Klassennamen zu vergeben. Wenn man beispielsweise eine Kartenkomponente erstellte, trennte man HTML und CSS wie folgt:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;span class="lnt">5
&lt;/span>&lt;span class="lnt">6
&lt;/span>&lt;span class="lnt">7
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-html" data-lang="html">&lt;span class="line">&lt;span class="cl">&lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">div&lt;/span> &lt;span class="na">class&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;card&amp;#34;&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">img&lt;/span> &lt;span class="na">class&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;card__image&amp;#34;&lt;/span> &lt;span class="na">src&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;image.jpg&amp;#34;&lt;/span> &lt;span class="na">alt&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;thumbnail&amp;#34;&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">div&lt;/span> &lt;span class="na">class&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;card__content&amp;#34;&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">h2&lt;/span> &lt;span class="na">class&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;card__title&amp;#34;&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>Titel&lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">h2&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">p&lt;/span> &lt;span class="na">class&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;card__description&amp;#34;&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>Die Beschreibung wird hier eingefügt.&lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">p&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">div&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">div&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-css" data-lang="css">&lt;span class="line">&lt;span class="cl">&lt;span class="p">.&lt;/span>&lt;span class="nc">card&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">border-radius&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="mi">8&lt;/span>&lt;span class="kt">px&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">box-shadow&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="mi">0&lt;/span> &lt;span class="mi">4&lt;/span>&lt;span class="kt">px&lt;/span> &lt;span class="mi">6&lt;/span>&lt;span class="kt">px&lt;/span> &lt;span class="nb">rgba&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="mf">0.1&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">background-color&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="mh">#ffffff&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">overflow&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="kc">hidden&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">.&lt;/span>&lt;span class="nc">card__title&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">font-size&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="mf">1.5&lt;/span>&lt;span class="kt">rem&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">font-weight&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="kc">bold&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">color&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="mh">#333333&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c">/* Im Folgenden würden detailliertere Stile stehen */&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Dieser auf BEM (Block Element Modifier) basierende Entwurf funktioniert bei kleinen Projekten gut, führt aber häufig zu den folgenden Problemen:&lt;/p>
&lt;ol>
&lt;li>&lt;strong>Erschöpfung und Ermüdung bei der Namensgebung&lt;/strong>: Jedes Mal, wenn eine ähnliche Komponente erstellt wird, muss man sich neue Klassennamen ausdenken (z. B. &lt;code>card-news&lt;/code>, &lt;code>card-featured&lt;/code>).&lt;/li>
&lt;li>&lt;strong>Aufblähen von CSS&lt;/strong>: Die Anzahl der CSS-Zeilen wächst mit jeder neuen Funktion, und einmal geschriebenes CSS wird selten gelöscht, aus Angst, man wisse nicht, &amp;ldquo;wo es verwendet wird&amp;rdquo;, wodurch sich toter Code ansammelt.&lt;/li>
&lt;li>&lt;strong>Kontextwechsel&lt;/strong>: Da HTML-Struktur und CSS-Stile in separaten Dateien verwaltet werden, steigt die Anzahl der Tab-Wechsel im Editor exponentiell an.&lt;/li>
&lt;/ol>
&lt;h3 id="paradigmenwechsel-durch-tailwind-css">Paradigmenwechsel durch Tailwind CSS
&lt;/h3>&lt;p>Tailwind CSS löst diese Probleme durch einen Ansatz, der auf der &amp;ldquo;Kombination von Utility-Klassen&amp;rdquo; basiert. Wenn wir Tailwind CSS auf die obige Kartenkomponente anwenden, sieht das so aus:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;span class="lnt">5
&lt;/span>&lt;span class="lnt">6
&lt;/span>&lt;span class="lnt">7
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-html" data-lang="html">&lt;span class="line">&lt;span class="cl">&lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">div&lt;/span> &lt;span class="na">class&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;rounded-lg shadow-md bg-white overflow-hidden&amp;#34;&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">img&lt;/span> &lt;span class="na">class&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;w-full h-48 object-cover&amp;#34;&lt;/span> &lt;span class="na">src&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;image.jpg&amp;#34;&lt;/span> &lt;span class="na">alt&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;thumbnail&amp;#34;&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">div&lt;/span> &lt;span class="na">class&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;p-6&amp;#34;&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">h2&lt;/span> &lt;span class="na">class&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;text-2xl font-bold text-gray-800&amp;#34;&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>Titel&lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">h2&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">p&lt;/span> &lt;span class="na">class&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;mt-2 text-gray-600&amp;#34;&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>Die Beschreibung wird hier eingefügt.&lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">p&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">div&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">div&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Da die Klassennamen selbst spezifische Stilwerte darstellen (&lt;code>p-6&lt;/code> steht z. B. für &lt;code>padding: 1.5rem;&lt;/code> usw.), kann man allein durch das Betrachten des HTMLs das endgültige Rendering-Ergebnis vorhersagen. Darüber hinaus extrahiert der JIT (Just-In-Time) Compiler von Tailwind nur die tatsächlich verwendeten Klassen in die endgültige CSS-Datei für die Produktion, wodurch die Dateigröße des CSS auf ein Minimum reduziert wird.&lt;/p>
&lt;hr>
&lt;h2 id="2-die-architektur-von-hugo-pipes-und-postcss">2. Die Architektur von Hugo Pipes und PostCSS
&lt;/h2>&lt;p>Um Tailwind CSS in Hugo zu integrieren, muss man die Asset-Verarbeitungs-Pipeline namens &lt;strong>Hugo Pipes&lt;/strong> verstehen. Hugo Pipes ist eine leistungsstarke Funktion, die alle assetbezogenen Prozesse – wie die Kompilierung von Sass/SCSS, das Bündeln und Minifizieren von JavaScript und die Ausführung von &lt;strong>PostCSS&lt;/strong>, das wir hier verwenden werden – innerhalb von Hugo selbst abschließt.&lt;/p>
&lt;p>PostCSS ist ein Tool zum Transformieren von CSS mithilfe von JavaScript-Plugins. Tatsächlich funktioniert auch Tailwind CSS selbst als PostCSS-Plugin.&lt;/p>
&lt;h3 id="der-ast-abstract-syntax-tree-transformationsmechanismus-in-postcss">Der AST (Abstract Syntax Tree) Transformationsmechanismus in PostCSS
&lt;/h3>&lt;p>Zu verstehen, wie PostCSS CSS verarbeitet, ist bei der Fehlersuche enorm hilfreich. Das folgende Mermaid-Diagramm zeigt die Pipeline, in der PostCSS eine CSS-Datei einliest, sie mithilfe von Plugins konvertiert und das endgültige CSS ausgibt.&lt;/p>
&lt;pre class="mermaid">
flowchart TD
A[&amp;#34;Rohes CSS (styles.css)&amp;#34;] --&amp;gt;|Parser| B[&amp;#34;AST (Abstrakter Syntaxbaum)&amp;#34;]
B --&amp;gt; C[&amp;#34;Plugin 1: Tailwind CSS&amp;#34;]
C --&amp;gt; D[&amp;#34;Plugin 2: Autoprefixer&amp;#34;]
D --&amp;gt; E[&amp;#34;Plugin N: cssnano&amp;#34;]
E --&amp;gt;|Stringifier| F[&amp;#34;Kompiliertes &amp;amp; optimiertes CSS&amp;#34;]
&lt;/pre>
&lt;ol>
&lt;li>&lt;strong>Parser&lt;/strong>: Analysiert die eingegebene rohe CSS-Zeichenfolge und wandelt sie in einen AST (Abstrakter Syntaxbaum) um, eine Datenstruktur, die programmgesteuert manipuliert werden kann.&lt;/li>
&lt;li>&lt;strong>Plugins&lt;/strong>:
&lt;ul>
&lt;li>&lt;strong>Tailwind CSS&lt;/strong>: Scannt Vorlagendateien (HTML oder Markdown) und fügt dem AST Knoten für die verwendeten Utility-Klassen hinzu. Es löst auch &lt;code>@tailwind&lt;/code>-Direktiven auf.&lt;/li>
&lt;li>&lt;strong>Autoprefixer&lt;/strong>: Bezieht sich auf die &lt;code>Can I Use&lt;/code>-Datenbank und fügt dem AST bei Bedarf Vendor-Präfixe (&lt;code>-webkit-&lt;/code>, &lt;code>-moz-&lt;/code> usw.) als Eigenschaften hinzu.&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>&lt;strong>Stringifier&lt;/strong>: Konvertiert den transformierten AST zurück in eine CSS-Zeichenfolge, die vom Browser interpretiert werden kann, und gibt diese aus.&lt;/li>
&lt;/ol>
&lt;hr>
&lt;h2 id="3-umgebungseinrichtung-und-voraussetzungen">3. Umgebungseinrichtung und Voraussetzungen
&lt;/h2>&lt;p>Lassen Sie uns nun mit dem eigentlichen Integrationsprozess beginnen. Zuerst überprüfen wir, ob die benötigte Software installiert ist.&lt;/p>
&lt;h3 id="voraussetzungen">Voraussetzungen
&lt;/h3>&lt;ol>
&lt;li>
&lt;p>&lt;strong>Hugo Extended Version&lt;/strong>:
Sie benötigen die &lt;strong>Extended-Version&lt;/strong>, die Sass/SCSS-Verarbeitungsfunktionen und native PostCSS-Integration enthält, anstelle der regulären Hugo-Version. Führen Sie den folgenden Befehl im Terminal aus und stellen Sie sicher, dass die Versionsinformationen die Zeichenfolge &lt;code>extended&lt;/code> enthalten.&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">hugo version
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># Erwartete Ausgabe:&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># hugo v0.121.2-4146... windows/amd64 BuildDate=... VendorInfo=gohugoio +extended&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;/li>
&lt;li>
&lt;p>&lt;strong>Node.js und npm&lt;/strong>:
Abhängigkeiten wie Tailwind CSS und PostCSS laufen auf Node.js. Stellen Sie sicher, dass Node.js (LTS-Version empfohlen) installiert ist.&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">node -v
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">npm -v
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;/li>
&lt;/ol>
&lt;h3 id="installation-der-npm-pakete">Installation der npm-Pakete
&lt;/h3>&lt;p>Initialisieren Sie npm im Stammverzeichnis Ihres Projekts (der Ebene, auf der sich Hugos Konfigurationsdatei &lt;code>hugo.toml&lt;/code> befindet) und installieren Sie die benötigten Pakete.&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;span class="lnt">5
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># Erzeugen der package.json&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">npm init -y
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># Installieren von Tailwind CSS, PostCSS und Autoprefixer als Entwicklungsabhängigkeiten&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">npm install -D tailwindcss postcss postcss-cli autoprefixer
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;blockquote>
&lt;p>[!IMPORTANT]
Wenn &lt;code>postcss-cli&lt;/code> nicht installiert ist, kann ein Fehler auftreten, wenn Hugo versucht, PostCSS intern aufzurufen. Hugo Pipes verwendet intern &lt;code>postcss-cli&lt;/code>, also stellen Sie sicher, dass es installiert ist.&lt;/p>
&lt;/blockquote>
&lt;hr>
&lt;h2 id="4-konfigurationsdateien-erstellen-postcss--tailwind-css">4. Konfigurationsdateien erstellen (PostCSS &amp;amp; Tailwind CSS)
&lt;/h2>&lt;p>Nachdem die Pakete installiert sind, erstellen wir zwei wichtige Konfigurationsdateien, die das Verhalten des Projekts steuern. Platzieren Sie diese im Stammverzeichnis Ihres Projekts.&lt;/p>
&lt;h3 id="erstellen-von-tailwindconfigjs">Erstellen von tailwind.config.js
&lt;/h3>&lt;p>Wenn Sie den folgenden Befehl in Ihrem Terminal ausführen, wird eine Standardkonfigurationsdatei generiert.&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">npx tailwindcss init
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Öffnen Sie die generierte Datei &lt;code>tailwind.config.js&lt;/code> in Ihrem Editor und konfigurieren Sie die Eigenschaft &lt;code>content&lt;/code>. Dies ist sehr wichtig. Tailwind analysiert die Dateien in den hier angegebenen Pfaden und extrahiert die verwendeten Klassen. Geben Sie die Layout- und Inhaltsdateien entsprechend der Projektstruktur von Hugo genau an.&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;span class="lnt">15
&lt;/span>&lt;span class="lnt">16
&lt;/span>&lt;span class="lnt">17
&lt;/span>&lt;span class="lnt">18
&lt;/span>&lt;span class="lnt">19
&lt;/span>&lt;span class="lnt">20
&lt;/span>&lt;span class="lnt">21
&lt;/span>&lt;span class="lnt">22
&lt;/span>&lt;span class="lnt">23
&lt;/span>&lt;span class="lnt">24
&lt;/span>&lt;span class="lnt">25
&lt;/span>&lt;span class="lnt">26
&lt;/span>&lt;span class="lnt">27
&lt;/span>&lt;span class="lnt">28
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-javascript" data-lang="javascript">&lt;span class="line">&lt;span class="cl">&lt;span class="cm">/** @type {import(&amp;#39;tailwindcss&amp;#39;).Config} */&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="nx">module&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">exports&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c1">// Scanziele entsprechend Hugos Verzeichnisstruktur angeben
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span> &lt;span class="nx">content&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">[&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="s2">&amp;#34;./content/**/*.md&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="s2">&amp;#34;./content/**/*.html&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="s2">&amp;#34;./layouts/**/*.html&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="s2">&amp;#34;./assets/**/*.js&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c1">// Wenn Sie ein Theme verwenden, müssen Sie auch dessen Verzeichnis einschließen
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span> &lt;span class="c1">// &amp;#34;./themes/my-theme/layouts/**/*.html&amp;#34;,
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span> &lt;span class="p">],&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">theme&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">extend&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c1">// Erweitern Sie hier benutzerdefinierte Farben oder Schriftarten
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span> &lt;span class="nx">colors&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="s1">&amp;#39;brand-primary&amp;#39;&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s1">&amp;#39;#3490dc&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="s1">&amp;#39;brand-secondary&amp;#39;&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s1">&amp;#39;#ffed4a&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">fontFamily&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="s1">&amp;#39;sans&amp;#39;&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="s1">&amp;#39;Helvetica Neue&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="s1">&amp;#39;Arial&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="s1">&amp;#39;Hiragino Kaku Gothic ProN&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="s1">&amp;#39;Meiryo&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="s1">&amp;#39;sans-serif&amp;#39;&lt;/span>&lt;span class="p">],&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">plugins&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">[&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c1">// Bei Bedarf offizielle Plugins hinzufügen (z. B. das Typography-Plugin)
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span> &lt;span class="c1">// require(&amp;#39;@tailwindcss/typography&amp;#39;),
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span> &lt;span class="p">],&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h3 id="erstellen-von-postcssconfigjs">Erstellen von postcss.config.js
&lt;/h3>&lt;p>Als Nächstes erstellen Sie &lt;code>postcss.config.js&lt;/code> im Stammverzeichnis des Projekts. Darin wird definiert, welche Plugins PostCSS in welcher Reihenfolge ausführt.&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;span class="lnt">5
&lt;/span>&lt;span class="lnt">6
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-javascript" data-lang="javascript">&lt;span class="line">&lt;span class="cl">&lt;span class="nx">module&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">exports&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">plugins&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">tailwindcss&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">{},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">autoprefixer&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">{},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Mit dieser Konfiguration führt Hugo, wenn es PostCSS aufruft, zuerst die Verarbeitung durch Tailwind CSS aus und wendet anschließend Autoprefixer an, um Vendor-Präfixe hinzuzufügen.&lt;/p>
&lt;hr>
&lt;h2 id="5-aufbau-der-css-asset-pipeline-in-hugo">5. Aufbau der CSS-Asset-Pipeline in Hugo
&lt;/h2>&lt;p>Sobald die Konfiguration abgeschlossen ist, ist es an der Zeit, Tailwind CSS in das Hugo-Theme zu integrieren.&lt;/p>
&lt;h3 id="5-1-erstellen-der-css-datei-als-einstiegspunkt">5-1. Erstellen der CSS-Datei als Einstiegspunkt
&lt;/h3>&lt;p>Erstellen Sie eine CSS-Datei als Einstiegspunkt im Verzeichnis &lt;code>assets/css/&lt;/code> (erstellen Sie es, falls es nicht existiert). Hier nennen wir sie &lt;code>main.css&lt;/code>.&lt;/p>
&lt;p>&lt;strong>Dateipfad: &lt;code>assets/css/main.css&lt;/code>&lt;/strong>&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;span class="lnt">15
&lt;/span>&lt;span class="lnt">16
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-css" data-lang="css">&lt;span class="line">&lt;span class="cl">&lt;span class="c">/* Laden der Basisstile von Tailwind (Reset CSS usw.) */&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">@&lt;/span>&lt;span class="k">tailwind&lt;/span> &lt;span class="nt">base&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c">/* Laden der Komponentenklassen */&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">@&lt;/span>&lt;span class="k">tailwind&lt;/span> &lt;span class="nt">components&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c">/* Laden der Utility-Klassen */&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">@&lt;/span>&lt;span class="k">tailwind&lt;/span> &lt;span class="nt">utilities&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c">/* Wenn Sie eigenes benutzerdefiniertes CSS benötigen, können Sie es hier hinzufügen,
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c"> es wird jedoch empfohlen, dafür wenn möglich die extend-Option in der tailwind.config.js zu nutzen */&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">@&lt;/span>&lt;span class="k">layer&lt;/span> &lt;span class="nt">components&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">.&lt;/span>&lt;span class="nc">btn-primary&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="err">@apply&lt;/span> &lt;span class="err">bg-blue-500&lt;/span> &lt;span class="n">hover&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="n">bg-blue-700&lt;/span> &lt;span class="kc">text&lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="kc">white&lt;/span> &lt;span class="k">font&lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="kc">bold&lt;/span> &lt;span class="n">py-2&lt;/span> &lt;span class="n">px-4&lt;/span> &lt;span class="n">rounded&lt;/span> &lt;span class="k">transition&lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="n">colors&lt;/span> &lt;span class="n">duration-300&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h3 id="5-2-bearbeiten-der-layout-datei-headhtml">5-2. Bearbeiten der Layout-Datei (head.html)
&lt;/h3>&lt;p>Als Nächstes weisen wir Hugos Template an, die oben genannte CSS-Datei zu laden, und definieren die Pipeline, um sie mit PostCSS zu verarbeiten. Im Allgemeinen wird das Partial-Template, das das &lt;code>&amp;lt;head&amp;gt;&lt;/code>-Tag definiert, (z. B. &lt;code>layouts/partials/head.html&lt;/code>) bearbeitet.&lt;/p>
&lt;p>&lt;strong>Dateipfad: &lt;code>layouts/partials/head.html&lt;/code>&lt;/strong>&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;span class="lnt">15
&lt;/span>&lt;span class="lnt">16
&lt;/span>&lt;span class="lnt">17
&lt;/span>&lt;span class="lnt">18
&lt;/span>&lt;span class="lnt">19
&lt;/span>&lt;span class="lnt">20
&lt;/span>&lt;span class="lnt">21
&lt;/span>&lt;span class="lnt">22
&lt;/span>&lt;span class="lnt">23
&lt;/span>&lt;span class="lnt">24
&lt;/span>&lt;span class="lnt">25
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-go-html-template" data-lang="go-html-template">&lt;span class="line">&lt;span class="cl">&lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">head&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">meta&lt;/span> &lt;span class="na">charset&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;utf-8&amp;#34;&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">meta&lt;/span> &lt;span class="na">name&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;viewport&amp;#34;&lt;/span> &lt;span class="na">content&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;width=device-width, initial-scale=1&amp;#34;&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">title&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>&lt;span class="cp">{{&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="na">.Title&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="cp">}}&lt;/span> | &lt;span class="cp">{{&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="na">.Site.Title&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="cp">}}&lt;/span>&lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">title&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c">&amp;lt;!-- Abrufen von assets/css/main.css --&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="cp">{{&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nx">$css&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">:=&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nx">resources&lt;/span>&lt;span class="na">.Get&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s">&amp;#34;css/main.css&amp;#34;&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="cp">}}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c">&amp;lt;!-- Definieren der PostCSS-Optionen --&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="cp">{{&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nx">$options&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">:=&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nx">dict&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s">&amp;#34;inlineImports&amp;#34;&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">true&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="cp">}}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="cp">{{&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nx">$css&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nx">$css&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nx">resources&lt;/span>&lt;span class="na">.PostCSS&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nx">$options&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="cp">}}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c">&amp;lt;!-- Asset-Optimierungspipeline für die Produktionsumgebung --&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="cp">{{&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">if&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nx">hugo&lt;/span>&lt;span class="na">.IsProduction&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="cp">}}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c">&amp;lt;!-- 1. Minify (Komprimierung) --&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="cp">{{&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nx">$css&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nx">$css&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nx">minify&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="cp">}}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c">&amp;lt;!-- 2. Fingerprint (Hinzufügen eines Hashes für Cache-Busting) --&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="cp">{{&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nx">$css&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nx">$css&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nx">fingerprint&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s">&amp;#34;sha512&amp;#34;&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="cp">}}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c">&amp;lt;!-- 3. Ausgeben des Tags mit SRI (Subresource Integrity) --&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">link&lt;/span> &lt;span class="na">rel&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;stylesheet&amp;#34;&lt;/span> &lt;span class="na">href&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;&lt;/span>&lt;span class="cp">{{&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nx">$css&lt;/span>&lt;span class="na">.RelPermalink&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="cp">}}&lt;/span>&lt;span class="s">&amp;#34;&lt;/span> &lt;span class="na">integrity&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;&lt;/span>&lt;span class="cp">{{&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nx">$css&lt;/span>&lt;span class="na">.Data.Integrity&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="cp">}}&lt;/span>&lt;span class="s">&amp;#34;&lt;/span> &lt;span class="na">crossorigin&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;anonymous&amp;#34;&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="cp">{{&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">else&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="cp">}}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c">&amp;lt;!-- In der Entwicklungsumgebung unkomprimiert ausgeben (Priorität auf Build-Geschwindigkeit) --&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">link&lt;/span> &lt;span class="na">rel&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;stylesheet&amp;#34;&lt;/span> &lt;span class="na">href&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;&lt;/span>&lt;span class="cp">{{&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nx">$css&lt;/span>&lt;span class="na">.RelPermalink&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="cp">}}&lt;/span>&lt;span class="s">&amp;#34;&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="cp">{{&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">end&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="cp">}}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">head&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h4 id="erläuterung-der-pipeline-und-mermaid-diagramm">Erläuterung der Pipeline und Mermaid-Diagramm
&lt;/h4>&lt;p>Im Folgenden wird erläutert, wie der obige Go-Template-Code die CSS-Datei verarbeitet, illustriert durch eine Reihe von Pipeline-Prozessen.&lt;/p>
&lt;pre class="mermaid">
flowchart TD
A[&amp;#34;assets/css/main.css&amp;#34;] --&amp;gt;|resources.Get| B[&amp;#34;Hugo-Speicherbereich&amp;#34;]
B --&amp;gt;|resources.PostCSS| C[&amp;#34;PostCSS + Tailwind JIT-Prozess&amp;#34;]
C --&amp;gt; D{&amp;#34;hugo.IsProduction ?&amp;#34;}
D -- &amp;#34;Ja (Produktionsumgebung)&amp;#34; --&amp;gt; E[&amp;#34;minify (Leerzeichen/Zeilenumbrüche entfernen)&amp;#34;]
E --&amp;gt; F[&amp;#34;fingerprint (Hash berechnen)&amp;#34;]
F --&amp;gt; G[&amp;#34;public/css/main.[hash].css (mit SRI)&amp;#34;]
D -- &amp;#34;Nein (Entwicklungsumgebung)&amp;#34; --&amp;gt; H[&amp;#34;public/css/main.css&amp;#34;]
&lt;/pre>
&lt;ol>
&lt;li>&lt;strong>&lt;code>resources.Get&lt;/code>&lt;/strong>: Sucht die angegebene Datei im Verzeichnis &lt;code>assets&lt;/code> und lädt sie als Ressourcenobjekt in den Speicher.&lt;/li>
&lt;li>&lt;strong>&lt;code>resources.PostCSS&lt;/code>&lt;/strong>: Verweist auf die &lt;code>postcss.config.js&lt;/code> im Stammverzeichnis des Projekts und wendet Tailwind CSS und Autoprefixer auf den CSS-Quellcode an. In der Entwicklungsumgebung (&lt;code>hugo server&lt;/code>) arbeitet der JIT-Modus und generiert beim Ändern von Dateien schnell nur die benötigten Klassen.&lt;/li>
&lt;li>&lt;strong>&lt;code>minify&lt;/code>&lt;/strong>: Entfernt beim Build für die Produktion (z. B. &lt;code>hugo --environment production&lt;/code>) unnötige Leerzeichen und Kommentare und minimiert die Dateigröße.&lt;/li>
&lt;li>&lt;strong>&lt;code>fingerprint&lt;/code>&lt;/strong>: Berechnet basierend auf dem Dateiinhalt einen SHA-Hash und hängt ihn an den Dateinamen an (z. B. &lt;code>main.ab12cd...css&lt;/code>). Dies ermöglicht ein &amp;ldquo;Cache-Busting&amp;rdquo;, was sicherstellt, dass neue Dateien zuverlässig geladen werden, wenn das CSS aktualisiert wird, während der leistungsstarke Cache des Browsers genutzt wird.&lt;/li>
&lt;li>&lt;strong>&lt;code>integrity&lt;/code>&lt;/strong>: Verwendet den durch den Fingerprint berechneten Hash-Wert, um ein SRI-Attribut auszugeben, das Manipulationen durch CDNs usw. verhindert.&lt;/li>
&lt;/ol>
&lt;hr>
&lt;h2 id="6-mathematische-leistungsanalyse-in-der-css-optimierung">6. Mathematische Leistungsanalyse in der CSS-Optimierung
&lt;/h2>&lt;p>Einer der größten Vorteile der Einführung von Tailwind CSS ist die Minimierung der ausgelieferten CSS-Dateigröße. Analysieren wir dies quantitativ mithilfe eines mathematischen Modells, um zu verstehen, wie sich dies auf die Web-Performance (insbesondere den First Contentful Paint: FCP) auswirkt.&lt;/p>
&lt;h3 id="modell-zur-reduzierung-der-css-dateigröße">Modell zur Reduzierung der CSS-Dateigröße
&lt;/h3>&lt;p>Bei traditionellen CSS-Frameworks (wie Bootstrap) wird das gesamte Framework geladen, einschließlich der nicht verwendeten Stile, was zu einer großen Dateigröße $S_{original}$ führt (ca. 150 KB bis 200 KB).
Wenn die Dateigröße nach Anwendung des Purge-Prozesses durch den JIT-Compiler von Tailwind CSS $S_{purged}$ ist, kann dies mit der Reduzierungsrate $R_{purge}$ wie folgt ausgedrückt werden:&lt;/p>
$$
S_{purged} = S_{original} \times (1 - R_{purge})
$$&lt;p>In einem typischen Projekt erreicht $R_{purge}$ nahezu $0.9$ (90% Reduzierung), wodurch $S_{purged}$ auf nur noch etwa 10 KB bis 20 KB sinkt.&lt;/p>
&lt;p>Zusätzlich erfolgt bei der Auslieferung eine Komprimierung auf der Serverseite mittels Brotli oder Gzip. Wenn die Komprimierungsrate $R_{compress}$ (typischerweise etwa 0,7 bis 0,8) beträgt, wird die endgültige Nutzlastgröße $S_{final}$, die über das Netzwerk übertragen wird, nach folgender Formel berechnet:&lt;/p>
$$
S_{final} = S_{purged} \times (1 - R_{compress})
$$&lt;h3 id="kritischer-rendering-pfad-und-netzwerklatenz">Kritischer Rendering-Pfad und Netzwerklatenz
&lt;/h3>&lt;p>Die Zeit, die der Browser benötigt, um die ersten Inhalte auf dem Bildschirm zu zeichnen (FCP), kann durch die Summe aus der HTML-Download-Zeit, der CSS-Download-Zeit und der Rendering-Zeit angenähert werden.&lt;/p>
$$
T_{FCP} \approx RTT + \frac{S_{HTML}}{BW} + RTT + \frac{S_{final}}{BW} + T_{render}
$$&lt;p>Hierbei ist:&lt;/p>
&lt;ul>
&lt;li>$RTT$ : Round Trip Time (Netzwerkverzögerung zwischen Client und Server)&lt;/li>
&lt;li>$BW$ : Netzwerkbandbreite (Bandwidth)&lt;/li>
&lt;/ul>
&lt;p>In Umgebungen mit schmaler $BW$ und hohem $RTT$ (hohe Latenz), wie z. B. in mobilen Netzwerken, minimiert der Ansatz von Tailwind CSS $S_{final}$ auf nur wenige Kilobyte. Dies treibt den Term $\frac{S_{final}}{BW}$ nahe Null und ist die treibende Kraft für das Erreichen unglaublicher Ergebnisse bei Tests (wie Google PageSpeed Insights).&lt;/p>
&lt;hr>
&lt;h2 id="7-starten-des-entwicklungsservers-und-bestätigung-des-hot-reloadings">7. Starten des Entwicklungsservers und Bestätigung des Hot-Reloadings
&lt;/h2>&lt;p>Nachdem alle Einstellungen vorgenommen wurden, starten Sie den Hugo-Entwicklungsserver und überprüfen Sie, ob Tailwind CSS ordnungsgemäß funktioniert.&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">hugo server -D
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Rufen Sie &lt;code>http://localhost:1313/&lt;/code> in Ihrem Browser auf und vergewissern Sie sich, dass die Website angezeigt wird.
Öffnen Sie eine Markdown-Inhaltsdatei oder ein Hugo-Template (die Dateien unter &lt;code>layouts/&lt;/code>) und versuchen Sie, einige Klassen hinzuzufügen.&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;span class="lnt">5
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-html" data-lang="html">&lt;span class="line">&lt;span class="cl">&lt;span class="c">&amp;lt;!-- Beispiel für die Anwendung von Tailwind-Klassen zum Testen --&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">div&lt;/span> &lt;span class="na">class&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;bg-gradient-to-r from-blue-500 to-purple-600 text-white p-8 rounded-xl shadow-2xl text-center transform transition duration-500 hover:scale-105&amp;#34;&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">h1&lt;/span> &lt;span class="na">class&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;text-4xl font-extrabold tracking-tight&amp;#34;&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>Tailwind CSS + Hugo ist großartig!&lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">h1&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">p&lt;/span> &lt;span class="na">class&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;mt-4 text-lg font-medium&amp;#34;&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>Vergewissern Sie sich, dass das Hot-Reloading sofort übernommen wird.&lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">p&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">div&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Sobald Sie die Datei speichern, arbeiten Hugos leistungsstarker File Watcher und der JIT-Compiler von Tailwind zusammen, um das CSS im Millisekundenbereich neu zu erstellen. Sie werden die Freude erleben, wenn der Browser automatisch neu geladen wird (Hot-Reload).&lt;/p>
&lt;h3 id="fehlerbehebung-wenn-stile-nicht-angewendet-werden">Fehlerbehebung: Wenn Stile nicht angewendet werden
&lt;/h3>&lt;p>Sollten die Änderungen nicht sichtbar sein, prüfen Sie bitte die folgenden Punkte:&lt;/p>
&lt;ol>
&lt;li>&lt;strong>Die Einstellung des &lt;code>content&lt;/code>-Pfads in &lt;code>tailwind.config.js&lt;/code>&lt;/strong>
Wenn der Pfad zu den zu scannenden Dateien falsch ist, kann Tailwind die in diesen Dateien verwendeten Klassen nicht erkennen und fügt sie dem CSS nicht hinzu. Überprüfen Sie insbesondere bei Verwendung eines Themes, ob der Pfad zum Theme-Verzeichnis fehlt.&lt;/li>
&lt;li>&lt;strong>PostCSS-Fehler&lt;/strong>
Wenn Sie in den Protokollen des Hugo-Servers in Ihrem Terminal Fehler wie &lt;code>Error: failed to transform resource: PostCSS not found&lt;/code> sehen, ist &lt;code>npm install&lt;/code> möglicherweise nicht erfolgreich ausgeführt worden, oder &lt;code>postcss-cli&lt;/code> fehlt.&lt;/li>
&lt;li>&lt;strong>Hugos Cache leeren&lt;/strong>
In seltenen Fällen kann durch Hugos Caching ein altes CSS erhalten bleiben. Versuchen Sie, den Server zu stoppen, ihn mit &lt;code>hugo server --ignoreCache&lt;/code> neu zu starten oder das temporäre Verzeichnis des Betriebssystems (z. B. &lt;code>/tmp/hugo_cache/&lt;/code>) zu löschen.&lt;/li>
&lt;/ol>
&lt;hr>
&lt;h2 id="8-build-für-die-produktion-und-weitere-verbesserungen">8. Build für die Produktion und weitere Verbesserungen
&lt;/h2>&lt;p>Wenn Sie Ihre Website auf einem Produktionsserver (z. B. Netlify, Vercel, GitHub Pages, Cloudflare Pages) bereitstellen, müssen Sie Umgebungsvariablen setzen und die Optimierungspipeline für die Produktion ausführen.&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># Beispiel für einen Produktions-Build-Befehl&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="nv">NODE_ENV&lt;/span>&lt;span class="o">=&lt;/span>production hugo --minify --environment production
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Durch das Hinzufügen des Flags &lt;code>--environment production&lt;/code> wird der &lt;code>{{ if hugo.IsProduction }}&lt;/code>-Block in der Datei &lt;code>head.html&lt;/code> ausgeführt, woraufhin das CSS minifiziert und der Fingerprint hinzugefügt wird.&lt;/p>
&lt;h3 id="markdown-styling-mit-dem-typography-plugin">Markdown-Styling mit dem Typography-Plugin
&lt;/h3>&lt;p>Auf Blog- oder Dokumentationsseiten wie bei Hugo können Klassen nicht direkt an die aus Markdown generierten reinen HTML-Elemente (&lt;code>&amp;lt;h1&amp;gt;&lt;/code>, &lt;code>&amp;lt;p&amp;gt;&lt;/code>, &lt;code>&amp;lt;ul&amp;gt;&lt;/code> usw.) angehängt werden. In solchen Fällen ist das offizielle &lt;strong>Typography-Plugin&lt;/strong> von Tailwind sehr nützlich.&lt;/p>
&lt;ol>
&lt;li>
&lt;p>Installieren Sie das Plugin&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">npm install -D @tailwindcss/typography
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;/li>
&lt;li>
&lt;p>Fügen Sie es zu &lt;code>tailwind.config.js&lt;/code> hinzu&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;span class="lnt">5
&lt;/span>&lt;span class="lnt">6
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-javascript" data-lang="javascript">&lt;span class="line">&lt;span class="cl">&lt;span class="nx">module&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">exports&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c1">// ...
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span> &lt;span class="nx">plugins&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">[&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">require&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;@tailwindcss/typography&amp;#39;&lt;/span>&lt;span class="p">),&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">],&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;/li>
&lt;li>
&lt;p>Anwendung im Template
Durch einfaches Hinzufügen der Klasse &lt;code>prose&lt;/code> (sowie optionaler Farb- und Größenvarianten) zum Container-Element, das den Artikelinhalt ausgibt, werden schöne Standardstile angewendet.&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-go-html-template" data-lang="go-html-template">&lt;span class="line">&lt;span class="cl">&lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">article&lt;/span> &lt;span class="na">class&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;prose prose-lg prose-blue mx-auto mt-10&amp;#34;&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="cp">{{&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="na">.Content&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="cp">}}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">article&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;/li>
&lt;/ol>
&lt;p>Dadurch müssen keine komplexen CSS-Selektoren (z. B. &lt;code>.article-content h2 { ... }&lt;/code>) manuell geschrieben werden, und die Modularität der Komponenten bleibt vollständig erhalten.&lt;/p>
&lt;hr>
&lt;h2 id="9-fazit-vollendung-eines-hochgradig-wartbaren-frontend-ökosystems">9. Fazit: Vollendung eines hochgradig wartbaren Frontend-Ökosystems
&lt;/h2>&lt;p>Gut gemacht! Damit ist die perfekte Webentwicklungs-Asset-Pipeline fertiggestellt, die die extrem schnelle Engine zur Generierung statischer Webseiten von Hugo mit den modernen Styling-Funktionen von Tailwind CSS und der Erweiterbarkeit von PostCSS vereint.&lt;/p>
&lt;p>Das Tolle an dieser Architektur ist, &lt;strong>&amp;ldquo;dass Sie sie nur einmal einrichten müssen&amp;rdquo;&lt;/strong>. Sobald die Pipeline eingerichtet ist, können Entwickler komplexe Benutzeroberflächen in rasanter Geschwindigkeit erstellen, ohne jemals eine CSS-Datei öffnen zu müssen, indem sie einfach intuitive Utility-Klassen in ihre HTML- oder Markdown-Templates schreiben.&lt;/p>
&lt;p>Da zudem die ausgegebene CSS-Größe stets minimiert wird, führt dies direkt zu besseren Core Web Vitals-Scores und ist aus SEO-Sicht sehr vorteilhaft.&lt;/p>
&lt;p>Die Kombination aus Hugo und Tailwind CSS wird für jedes Projekt, vom persönlichen Tech-Blog bis zur großen Unternehmens-Website, weiterhin eine der &amp;ldquo;besten Entscheidungen&amp;rdquo; sein. Nutzen Sie diese mächtige Toolchain auf jeden Fall und genießen Sie ein komfortables Web-Entwicklungsleben!&lt;/p></description></item><item><title>Einführung in den Static Site Generator mit Hugo (Migrationsanleitung von WordPress)</title><link>http://kenji.blog/de/p/hugo-static-site-generator-wordpress-migration/</link><pubDate>Sun, 13 Sep 2026 02:00:00 +0900</pubDate><guid>http://kenji.blog/de/p/hugo-static-site-generator-wordpress-migration/</guid><description>&lt;img src="http://kenji.blog/p/hugo-static-site-generator-wordpress-migration/img/eyecatch.jpg" alt="Featured image of post Einführung in den Static Site Generator mit Hugo (Migrationsanleitung von WordPress)" />&lt;p>In der modernen Webentwicklung und beim Betrieb von Blogs sind Ladegeschwindigkeit, Sicherheit und Wartbarkeit von entscheidender Bedeutung. &amp;ldquo;WordPress&amp;rdquo;, das lange Zeit einen überwältigenden Marktanteil als Basis für Blogs und Unternehmenswebsites hatte, wird von vielen Nutzern wegen seines flexiblen Plugin-Ökosystems und seiner intuitiven Verwaltungsoberfläche geschätzt. Da es jedoch die Kommunikation mit einer Datenbank und die dynamische Seitengenerierung auf der Serverseite (Verarbeitung durch PHP) erfordert, weist es Schwachstellen wie Anfälligkeit bei plötzlichen Traffic-Spitzen und Anzeigeverzögerungen (Latenz) auf.&lt;/p>
&lt;p>Aus diesem Grund erfreuen sich &amp;ldquo;Static Site Generators (SSG)&amp;rdquo; in den letzten Jahren rasant wachsender Beliebtheit. In diesem Artikel werden wir uns eingehend mit &amp;ldquo;&lt;strong>Hugo&lt;/strong>&amp;rdquo; befassen, einem der vielen SSGs, der auf der Programmiersprache Go basiert und für seine unglaubliche Build-Geschwindigkeit bekannt ist. Wir werden alles im Detail erklären, angefangen bei einem Vergleich der technischen Architektur mit dynamischen CMS (Content Management Systemen) wie WordPress, über konkrete Migrationsschritte und Leistungsbewertungen mithilfe mathematischer Modelle, bis hin zu Hugos spezifischer Verzeichnisstruktur und der Suchreihenfolge von Vorlagen (Template Lookup Order).&lt;/p>
&lt;hr>
&lt;h2 id="1-technische-unterschiede-zwischen-dynamischem-cms-wordpress-und-static-site-generator-hugo">1. Technische Unterschiede zwischen dynamischem CMS (WordPress) und Static Site Generator (Hugo)
&lt;/h2>&lt;p>Wenn es um die Bereitstellung einer Website geht, verfolgen WordPress und Hugo grundlegend unterschiedliche Ansätze.&lt;/p>
&lt;h3 id="11-die-architektur-von-wordpress-dynamische-generierung">1.1 Die Architektur von WordPress (Dynamische Generierung)
&lt;/h3>&lt;p>WordPress ist ein typisches dynamisches CMS, das Seiten bei jeder Anfrage (Request) serverseitig zusammenstellt. Wenn ein Benutzer (Browser) auf eine Seite zugreift, führt der Webserver (z. B. Apache, Nginx) ein PHP-Skript aus und sendet eine Anfrage (Query) an eine relationale Datenbank wie MySQL (oder MariaDB). Der aus der Datenbank abgerufene Inhalt (Artikeldaten, Kategorien, Tags, Website-Einstellungen usw.) wird mit Vorlagendateien (Templates) kombiniert, um den endgültigen HTML-Code zu generieren und an den Client zurückzugeben.&lt;/p>
&lt;p>Dieser Mechanismus hat den Vorteil, dass für jeden Besucher individuelle Inhalte in Echtzeit generiert werden können (z. B. Warenkörbe auf E-Commerce-Websites, exklusive Seiten für eingeloggte Benutzer). Ohne eine angemessen gestaltete Caching-Infrastruktur (wie Reverse-Proxys oder Plugins) verbraucht er jedoch massiv Serverressourcen.&lt;/p>
&lt;h3 id="12-die-architektur-von-hugo-vorab-generierung-zur-build-zeit">1.2 Die Architektur von Hugo (Vorab-Generierung zur Build-Zeit)
&lt;/h3>&lt;p>Andererseits generiert Hugo, wie der Name &amp;ldquo;Static Site Generator&amp;rdquo; schon sagt, Inhalte nicht zur &amp;ldquo;Anfragezeit&amp;rdquo;, sondern zur &amp;ldquo;Build-Zeit&amp;rdquo;. Die Inhalte werden nicht in einer Datenbank, sondern als lokale &amp;ldquo;Markdown-Dateien&amp;rdquo; verwaltet, die mit Versionskontrollsystemen wie Git versioniert werden.
Wenn der Entwickler den Befehl (&lt;code>hugo&lt;/code>) ausführt, liest Hugo die Markdown-Dateien ein, fügt die Daten in die angegebenen HTML-Vorlagen (Layout-Dateien) ein und generiert eine Sammlung vollständiger, reiner HTML/CSS/JS-Dateien.&lt;/p>
&lt;p>Die generierten Dateien (statische Assets) können einfach durch Platzieren in einer &amp;ldquo;statischen Hosting-Umgebung&amp;rdquo; wie Amazon S3, Cloudflare Pages, Netlify, Vercel oder einem einfachen Nginx-Server bereitgestellt werden. Da weder eine Datenbank noch eine serverseitige Sprache (wie PHP) erforderlich sind, werden Sicherheitsrisiken (wie SQL-Injection oder PHP-Schwachstellen) drastisch reduziert, und die Auslieferungsgeschwindigkeit wird extrem maximiert, da die Daten auf Edge-Nodes eines CDN (Content Delivery Network) zwischengespeichert (gecacht) werden.&lt;/p>
&lt;p>Nachfolgend veranschaulicht ein Mermaid-Diagramm die Unterschiede zwischen den beiden Architekturen.&lt;/p>
&lt;pre class="mermaid">
flowchart TD
subgraph WordPress[&amp;#34;Dynamisches CMS (WordPress)&amp;#34;]
direction TB
Req1[&amp;#34;Benutzeranfrage&amp;#34;] --&amp;gt; WebServer1[&amp;#34;Webserver (Nginx/Apache)&amp;#34;]
WebServer1 --&amp;gt; PHP[&amp;#34;PHP-Verarbeitung&amp;#34;]
PHP &amp;lt;--&amp;gt; DB[&amp;#34;Datenbank (MySQL)&amp;#34;]
PHP --&amp;gt; HTML1[&amp;#34;HTML-Generierung&amp;#34;]
HTML1 --&amp;gt; Res1[&amp;#34;Antwortrückgabe&amp;#34;]
end
subgraph Hugo[&amp;#34;Static Site Generator (Hugo)&amp;#34;]
direction TB
Dev[&amp;#34;Entwickler / CI・CD&amp;#34;] --&amp;gt; HugoBuild[&amp;#34;Hugo-Build-Prozess&amp;#34;]
Markdown[&amp;#34;Markdown-Dateien&amp;#34;] --&amp;gt; HugoBuild
Templates[&amp;#34;Vorlagen (HTML)&amp;#34;] --&amp;gt; HugoBuild
HugoBuild --&amp;gt; StaticFiles[&amp;#34;Statische Dateien (HTML/CSS/JS)&amp;#34;]
StaticFiles --&amp;gt; CDN[&amp;#34;CDN / Statisches Hosting&amp;#34;]
Req2[&amp;#34;Benutzeranfrage&amp;#34;] --&amp;gt; CDN
CDN --&amp;gt; Res2[&amp;#34;Sofortige Antwortrückgabe&amp;#34;]
end
&lt;/pre>
&lt;hr>
&lt;h2 id="2-leistungsbewertung-anhand-eines-mathematischen-modells">2. Leistungsbewertung anhand eines mathematischen Modells
&lt;/h2>&lt;p>Einer der größten Vorteile der Migration von WordPress zu Hugo ist die Verbesserung der Leistung (Ladegeschwindigkeit). Um dies quantitativ zu verstehen, wollen wir es mit einem einfachen mathematischen Modell ausdrücken.&lt;/p>
&lt;p>Die Zeit bis zum Abschluss des Ladens einer Seite (Load Time: $T_{load}$) lässt sich grob in die Antwortzeit des Servers (TTFB: Time To First Byte) und die Zeit für Rendering und Ressourcenbeschaffung durch den Browser ($T_{render}$) unterteilen.&lt;/p>
$$ T_{load} = T_{ttfb} + T_{render} $$&lt;p>Bei einem dynamischen CMS (WordPress) ist $T_{ttfb}$ die Summe der folgenden Faktoren: Netzwerkverzögerung ($T_{network}$), Skriptausführungszeit auf der Serverseite ($T_{php}$) und Abfrageverarbeitungszeit der Datenbank ($T_{db}$).&lt;/p>
$$ T_{ttfb\_wp} = T_{network} + T_{php} + T_{db} $$&lt;p>Bei hoher Zugriffsrate (hoher Last) steigen $T_{php}$ und $T_{db}$ nichtlinear an, und das gesamte System kann zum Engpass werden. Mathematisch ausgedrückt zeigt sich bei einer Anzahl von Anfragen ($N$) die folgende Verschlechterung der Antwortzeit ($k$ ist der Overhead-Koeffizient der Verarbeitung).&lt;/p>
$$ T_{php}(N) \approx O(N^k), \quad T_{db}(N) \approx O(N^k) \quad \text{where } k > 1 $$&lt;p>Andererseits gibt es bei einer Architektur, die einen Static Site Generator (Hugo) mit einem CDN kombiniert, keine serverseitige dynamische Verarbeitung (PHP oder DB-Abfragen). Da die Inhalte auf weltweit verteilten Edge-Servern zwischengespeichert werden, hängt $T_{ttfb}$ rein von der Netzwerkverzögerung zum nächstgelegenen Edge-Server des Clients ab ($T_{edge}$).&lt;/p>
$$ T_{ttfb\_hugo} = T_{edge} $$&lt;p>Dadurch gilt $T_{edge} \ll (T_{network} + T_{php} + T_{db})$, und die TTFB wird drastisch auf wenige bis einige Dutzend Millisekunden verkürzt. Darüber hinaus bleibt die Antwortzeit aufgrund der Lastausgleichsfunktion der Edge-Server nahezu konstant ($O(1)$), selbst wenn die Anzahl der Anfragen $N$ steigt.&lt;/p>
$$ \lim_{N \to \infty} T_{ttfb\_hugo}(N) \approx \text{Konstant} $$&lt;p>Dies ist die mathematische Grundlage dafür, warum Hugo (eine statische Website) extrem robust gegenüber Traffic-Spitzen (z. B. wenn ein Beitrag viral geht) ist.&lt;/p>
&lt;hr>
&lt;h2 id="3-grundstruktur-und-funktionsprinzip-von-hugo">3. Grundstruktur und Funktionsprinzip von Hugo
&lt;/h2>&lt;p>Um Hugo zu beherrschen, ist es unerlässlich, seine einzigartige Verzeichnisstruktur und die Konzepte von &amp;ldquo;Front Matter&amp;rdquo; und &amp;ldquo;Template Lookup Order&amp;rdquo; zu verstehen.&lt;/p>
&lt;h3 id="31-detaillierte-erklärung-der-verzeichnisstruktur">3.1 Detaillierte Erklärung der Verzeichnisstruktur
&lt;/h3>&lt;p>Wenn Sie ein neues Hugo-Projekt erstellen (&lt;code>hugo new site mysite&lt;/code>), wird die folgende Verzeichnisstruktur generiert:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-text" data-lang="text">&lt;span class="line">&lt;span class="cl">mysite/
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">├── archetypes/ # Vorlagen beim Erstellen neuer Inhalte (Front Matter-Vorlagen)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">├── assets/ # Dateien, die von Hugo Pipes verarbeitet werden (SCSS/Sass, JavaScript usw.)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">├── content/ # Der tatsächliche Website-Inhalt (Markdown-Dateien). Dies ersetzt die DB.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">├── data/ # Externe Daten und Einstellungen, die site-weit verwendet werden (JSON, TOML, YAML, CSV usw.)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">├── layouts/ # HTML-Vorlagen, die das Aussehen der Site bestimmen (verwendet Go html/template)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">├── public/ # Der Ort, an dem die generierten statischen Dateien nach der Build-Ausführung ausgegeben werden
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">├── static/ # Statische Dateien, die unverändert veröffentlicht werden (Bilder, Favicons, robots.txt usw.)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">├── themes/ # Verzeichnis für Themes von Drittanbietern oder selbst erstellte Themes
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">└── hugo.toml # Die site-weite Konfigurationsdatei (früher war config.toml üblich)
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>In WordPress werden Inhalte in der &lt;code>wp_posts&lt;/code>-Tabelle von MySQL gespeichert, aber in Hugo werden alle als Textdateien (hauptsächlich Markdown) im &lt;code>content/&lt;/code>-Verzeichnis verwaltet. Dies macht die Versionskontrolle von Inhalten (Git) einfach.&lt;/p>
&lt;h3 id="32-inhaltsverwaltung-markdown-und-front-matter">3.2 Inhaltsverwaltung: Markdown und Front Matter
&lt;/h3>&lt;p>Jede Artikeldatei in Hugo besteht aus einem Metadatenblock namens &amp;ldquo;Front Matter&amp;rdquo; ganz oben, gefolgt vom Haupttext (Markdown) darunter. Front Matter kann in TOML, YAML oder JSON geschrieben werden, aber YAML ist am weitesten verbreitet.&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-yaml" data-lang="yaml">&lt;span class="line">&lt;span class="cl">&lt;span class="nn">---&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">title&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;Die Taxonomie von Hugo verstehen&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">date&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="ld">2026-09-13T10:00:00&lt;/span>&lt;span class="m">+09&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="m">00&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">draft&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="kc">false&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">categories&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>- &lt;span class="s2">&amp;#34;Technische Erklärung&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">tags&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>- &lt;span class="s2">&amp;#34;Hugo&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>- &lt;span class="s2">&amp;#34;Go&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">aliases&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>- &lt;span class="s2">&amp;#34;/old-category/hugo-taxonomy/&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nn">---&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="l">Hier beginnt der Haupttext. Er ist in **Markdown** geschrieben.&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="l">Wir werden die leistungsstarken Funktionen von Hugo erklären...&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Bemerkenswert ist hier der &lt;code>aliases&lt;/code>-Schlüssel. Bei der Migration von WordPress ist es für SEO-Zwecke ein großer Nachteil, wenn sich Permalinks (URLs) ändern. Durch die Verwendung der Alias-Funktion von Hugo generiert Hugo automatisch HTML für Weiterleitungen (Transfer durch Meta-Refresh), indem Sie einfach die alte URL angeben. Dies ist äußerst praktisch, da serverseitige Weiterleitungseinstellungen (wie .htaccess) nicht mehr erforderlich sind.&lt;/p>
&lt;h3 id="33-vorlagen-suchreihenfolge-template-lookup-order">3.3 Vorlagen-Suchreihenfolge (Template Lookup Order)
&lt;/h3>&lt;p>Eine der leistungsstärksten Funktionen von Hugo ist sein flexibler Vorlagen-Suchmechanismus (Template Lookup Order). Beim Rendern einer bestimmten Seite durchsucht Hugo Verzeichnisse und Dateinamen in einer bestimmten Reihenfolge, um die optimale Vorlage zu finden.&lt;/p>
&lt;p>Wenn beispielsweise ein einzelner Artikel (Single Page) namens &lt;code>content/post/hello-world.md&lt;/code> gerendert wird, sucht Hugo im Allgemeinen in der folgenden Reihenfolge nach Layoutdateien:&lt;/p>
&lt;ol>
&lt;li>&lt;code>layouts/post/single.html&lt;/code>&lt;/li>
&lt;li>&lt;code>layouts/post/list.html&lt;/code> (Nicht falsch, aber normalerweise für Listen)&lt;/li>
&lt;li>&lt;code>layouts/_default/single.html&lt;/code>&lt;/li>
&lt;li>&lt;code>themes/&amp;lt;THEME_NAME&amp;gt;/layouts/post/single.html&lt;/code>&lt;/li>
&lt;li>&lt;code>themes/&amp;lt;THEME_NAME&amp;gt;/layouts/_default/single.html&lt;/code>&lt;/li>
&lt;/ol>
&lt;p>Entwickler können die Vorlagen eines Themes &lt;strong>überschreiben (overriden)&lt;/strong>, indem sie einfach eine gleichnamige Datei im &lt;code>layouts/&lt;/code>-Verzeichnis ihres eigenen Projekts erstellen, ohne den Quellcode des Themes direkt zu ändern. Auf diese Weise können Sie eigene Anpassungen vornehmen, ohne zukünftige Updates des zugrunde liegenden Themes zu behindern.&lt;/p>
&lt;h3 id="34-taxonomie-taxonomy">3.4 Taxonomie (Taxonomy)
&lt;/h3>&lt;p>Das Klassifizierungssystem, das in WordPress den &amp;ldquo;Kategorien&amp;rdquo; und &amp;ldquo;Tags&amp;rdquo; entspricht, wird in Hugo als &amp;ldquo;Taxonomie (Taxonomy)&amp;rdquo; bezeichnet.
Hugo unterstützt standardmäßig die Taxonomien &lt;code>categories&lt;/code> und &lt;code>tags&lt;/code>, aber durch Bearbeiten der &lt;code>hugo.toml&lt;/code> können Sie nach Belieben benutzerdefinierte Taxonomien (z. B. &lt;code>series&lt;/code>, &lt;code>authors&lt;/code> usw.) hinzufügen.&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;span class="lnt">5
&lt;/span>&lt;span class="lnt">6
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-toml" data-lang="toml">&lt;span class="line">&lt;span class="cl">&lt;span class="c"># Beispiel für hugo.toml&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">[&lt;/span>&lt;span class="nx">taxonomies&lt;/span>&lt;span class="p">]&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">category&lt;/span> &lt;span class="p">=&lt;/span> &lt;span class="s2">&amp;#34;categories&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">tag&lt;/span> &lt;span class="p">=&lt;/span> &lt;span class="s2">&amp;#34;tags&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">series&lt;/span> &lt;span class="p">=&lt;/span> &lt;span class="s2">&amp;#34;series&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">author&lt;/span> &lt;span class="p">=&lt;/span> &lt;span class="s2">&amp;#34;authors&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Dies ermöglicht es, Inhalte auf vielfältige Weise zu organisieren und aufzulisten.&lt;/p>
&lt;hr>
&lt;h2 id="4-migrationsprozess-von-wordpress-zu-hugo-migration">4. Migrationsprozess von WordPress zu Hugo (Migration)
&lt;/h2>&lt;p>Der Schlüssel zu einer erfolgreichen Migration von WordPress zu Hugo liegt darin, wie man die dynamischen Inhalte in der Datenbank sauber in statische Dateien (Markdown + Front Matter) konvertiert und dabei die vorhandene URL-Struktur beibehält.&lt;/p>
&lt;p>Im Folgenden ist der Ablauf einer typischen Migrations-Pipeline dargestellt.&lt;/p>
&lt;pre class="mermaid">
flowchart LR
WPDB[&amp;#34;WP-Datenbank&amp;#34;] --&amp;gt;|Plugin| Exporter[&amp;#34;Export-Tool&amp;#34;]
Exporter --&amp;gt;|&amp;#34;Extrahiert Text, \nMetadaten, Bilder&amp;#34;| ZipFile[&amp;#34;Zip / Ordner&amp;#34;]
ZipFile --&amp;gt;|Entpacken| MarkdownFiles[&amp;#34;Markdown-Dateien \n(content/)&amp;#34;]
ZipFile --&amp;gt;|Entpacken| ImageFiles[&amp;#34;Bilder \n(static/wp-content/)&amp;#34;]
MarkdownFiles --&amp;gt; Formatting[&amp;#34;Überprüfen &amp;amp; Formatieren \n(Shortcodes reparieren)&amp;#34;]
Formatting --&amp;gt; Git[&amp;#34;An Git übergeben&amp;#34;]
&lt;/pre>
&lt;h3 id="41-datenextraktion-und-markdown-konvertierung">4.1 Datenextraktion und Markdown-Konvertierung
&lt;/h3>&lt;p>Um WordPress-Daten für Hugo auszugeben, ist die Verwendung eines dedizierten Plugins der einfachste und zuverlässigste Weg. Hier sind einige typische Ansätze.&lt;/p>
&lt;ol>
&lt;li>&lt;strong>Verwendung des Jekyll Exporter-Plugins&lt;/strong>
Da Hugo eine sehr ähnliche Datenstruktur wie Jekyll, ein anderer SSG, aufweist, ist die Verwendung des &amp;ldquo;Jekyll Exporter&amp;rdquo;-Plugins für WordPress eine gängige Methode. Wenn Sie dieses Plugin installieren und ausführen, werden alle Beiträge und statischen Seiten in Markdown-Dateien mit Front Matter konvertiert und können zusammen mit den Bilddateien als ZIP-Datei heruntergeladen werden.&lt;/li>
&lt;li>&lt;strong>Eigenes Skript mit der WordPress API&lt;/strong>
Dies ist eine Methode, bei der Sie mit Python, Node.js usw. auf die WordPress REST API (&lt;code>/wp-json/wp/v2/posts&lt;/code>) zugreifen, die JSON-Daten parsen und Ihr eigenes Skript erstellen, um die Markdown-Dateien selbst zu generieren. Dies ist effektiv für Websites, die intensiv komplexe benutzerdefinierte Felder (wie ACF) verwenden, die nicht vollständig von Plugins verarbeitet werden können.&lt;/li>
&lt;li>&lt;strong>Nutzung des wp2hugo-Tools&lt;/strong>
Es gibt auch einen Ansatz, ein in Go geschriebenes CLI-Tool zu verwenden, um direkt von einer WordPress-Export-XML-Datei (WXR) in das Hugo-Format zu konvertieren.&lt;/li>
&lt;/ol>
&lt;h3 id="42-beibehaltung-der-permalink-url-struktur">4.2 Beibehaltung der Permalink-(URL)-Struktur
&lt;/h3>&lt;p>Um die SEO-Bewertung aufrechtzuerhalten, ist es extrem wichtig, die URL aus der WordPress-Ära unverändert zu übernehmen. Wenn Ihre Permalink-Einstellung in WordPress &lt;code>https://example.com/2026/09/13/my-post/&lt;/code> war, geben Sie diese Permalink-Struktur in der &lt;code>hugo.toml&lt;/code> von Hugo an.&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-toml" data-lang="toml">&lt;span class="line">&lt;span class="cl">&lt;span class="p">[&lt;/span>&lt;span class="nx">permalinks&lt;/span>&lt;span class="p">]&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">post&lt;/span> &lt;span class="p">=&lt;/span> &lt;span class="s2">&amp;#34;/:year/:month/:day/:slug/&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Alternativ ist es auch möglich, die URL zwangsweise zu fixieren, indem Sie den &lt;code>url&lt;/code>-Parameter direkt im Front Matter jedes Artikels angeben.
Zusätzlich richten Sie für Seiten, deren URL sich ändert, Weiterleitungen mithilfe der zuvor erwähnten &lt;code>aliases&lt;/code> ein.&lt;/p>
&lt;h3 id="43-konvertierung-von-shortcodes">4.3 Konvertierung von Shortcodes
&lt;/h3>&lt;p>WordPress-spezifische Shortcodes (z. B. &lt;code>[gallery]&lt;/code>, &lt;code>[caption]&lt;/code>, benutzerdefinierte Codes verschiedener Plugins) bleiben beim Export oft als bloße Zeichenfolgen erhalten, daher muss dies behoben werden.
Diese werden entweder in großen Mengen mithilfe von Ersetzungsskripten (sed oder Python) gelöscht oder Sie verwenden Hugos leistungsstarke &lt;strong>Custom Shortcode-Funktion&lt;/strong> (erstellen Sie benutzerdefinierte Layouts in &lt;code>layouts/shortcodes/&lt;/code>), um sie so zu migrieren, dass sie auf der Hugo-Seite korrekt gerendert werden.&lt;/p>
&lt;hr>
&lt;h2 id="5-hugos-cli-tool-und-builddeploy">5. Hugos CLI-Tool und Build/Deploy
&lt;/h2>&lt;p>Sobald die Migrationsarbeit abgeschlossen ist, ist es endlich Zeit, die Website mit Hugo zu erstellen und sie der Welt zu präsentieren. Hugo, bereitgestellt als Go-Binärdatei, rühmt sich einer unglaublichen Geschwindigkeit, mit der Builds selbst für Websites mit Tausenden oder Zehntausenden von Seiten in nur wenigen Sekunden abgeschlossen werden.&lt;/p>
&lt;h3 id="51-starten-des-lokalen-entwicklungsservers">5.1 Starten des lokalen Entwicklungsservers
&lt;/h3>&lt;p>Wenn Sie Artikel schreiben oder das Design anpassen, starten Sie den lokalen Server.&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># Befehl zum Starten des Entwicklungsservers (verwenden Sie -D, um Entwürfe einzuschließen)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">hugo server -D
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Wenn Sie diesen Befehl ausführen, kann die Website unter &lt;code>http://localhost:1313/&lt;/code> in der Vorschau angezeigt werden. Hugo verfügt über eine integrierte, leistungsstarke &amp;ldquo;LiveReload&amp;rdquo;-Funktion. In dem Moment, in dem Sie eine Markdown-Datei, eine Vorlage oder CSS bearbeiten und speichern, wird der Browserbildschirm automatisch in hoher Geschwindigkeit aktualisiert. Dadurch wird das Schreib- und Entwicklungserlebnis weitaus komfortabler als die Verwaltungsoberfläche von WordPress.&lt;/p>
&lt;h3 id="52-produktions-build-und-leistungsoptimierung">5.2 Produktions-Build und Leistungsoptimierung
&lt;/h3>&lt;p>Um die statischen Dateien für die Bereitstellung in der Produktionsumgebung zu generieren, geben Sie einfach &lt;code>hugo&lt;/code> ein.&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># Produktions-Build ausführen. Die Option --minify minimiert HTML/CSS/JS&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">hugo --minify
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Mit diesem Befehl werden alle Dateien der gesamten Website im &lt;code>public/&lt;/code>-Verzeichnis ausgegeben. Durch Hinzufügen der Option &lt;code>--minify&lt;/code> werden unnötige Zeilenumbrüche und Leerzeichen entfernt, was die Dateigröße weiter reduziert. Dies trägt direkt zur Reduzierung der Netzwerkverzögerung ($T_{network}$) im zuvor erwähnten mathematischen Modell bei.&lt;/p>
&lt;h3 id="53-bereitstellungsautomatisierung-cicd">5.3 Bereitstellungsautomatisierung (CI/CD)
&lt;/h3>&lt;p>Es ist ineffizient, jedes Mal statische Dateien auf einem lokalen PC zu generieren und per FTP oder Ähnlichem hochzuladen. Im modernen SSG-Betrieb ist es die beste Vorgehensweise (Best Practice), eine CI/CD-Umgebung aufzubauen, die automatisch Builds und Bereitstellungen (Deployments) durchführt, ausgelöst durch einen Push in ein Git-Repository (wie GitHub).&lt;/p>
&lt;p>Die Grundform einer Konfiguration (YAML-Datei) für die Bereitstellung auf Cloudflare Pages oder GitHub Pages mithilfe von GitHub Actions sieht beispielsweise wie folgt aus.&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;span class="lnt">15
&lt;/span>&lt;span class="lnt">16
&lt;/span>&lt;span class="lnt">17
&lt;/span>&lt;span class="lnt">18
&lt;/span>&lt;span class="lnt">19
&lt;/span>&lt;span class="lnt">20
&lt;/span>&lt;span class="lnt">21
&lt;/span>&lt;span class="lnt">22
&lt;/span>&lt;span class="lnt">23
&lt;/span>&lt;span class="lnt">24
&lt;/span>&lt;span class="lnt">25
&lt;/span>&lt;span class="lnt">26
&lt;/span>&lt;span class="lnt">27
&lt;/span>&lt;span class="lnt">28
&lt;/span>&lt;span class="lnt">29
&lt;/span>&lt;span class="lnt">30
&lt;/span>&lt;span class="lnt">31
&lt;/span>&lt;span class="lnt">32
&lt;/span>&lt;span class="lnt">33
&lt;/span>&lt;span class="lnt">34
&lt;/span>&lt;span class="lnt">35
&lt;/span>&lt;span class="lnt">36
&lt;/span>&lt;span class="lnt">37
&lt;/span>&lt;span class="lnt">38
&lt;/span>&lt;span class="lnt">39
&lt;/span>&lt;span class="lnt">40
&lt;/span>&lt;span class="lnt">41
&lt;/span>&lt;span class="lnt">42
&lt;/span>&lt;span class="lnt">43
&lt;/span>&lt;span class="lnt">44
&lt;/span>&lt;span class="lnt">45
&lt;/span>&lt;span class="lnt">46
&lt;/span>&lt;span class="lnt">47
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-yaml" data-lang="yaml">&lt;span class="line">&lt;span class="cl">&lt;span class="c"># Beispiel für .github/workflows/hugo.yml&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">name&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">Deploy Hugo site to GitHub Pages&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">on&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">push&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">branches&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="s2">&amp;#34;main&amp;#34;&lt;/span>&lt;span class="p">]&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">workflow_dispatch&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">permissions&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">contents&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">read&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">pages&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">write&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">id-token&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">write&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">jobs&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">build&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">runs-on&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">ubuntu-latest&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">steps&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>- &lt;span class="nt">name&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">Checkout&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">uses&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">actions/checkout@v3&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">with&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">submodules&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">recursive&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="c"># Wenn Themes als Submodule verwaltet werden&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">fetch-depth&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="m">0&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>- &lt;span class="nt">name&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">Setup Hugo&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">uses&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">peaceiris/actions-hugo@v2&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">with&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">hugo-version&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s1">&amp;#39;latest&amp;#39;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">extended&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="kc">true&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>- &lt;span class="nt">name&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">Build&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">run&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">hugo --minify&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>- &lt;span class="nt">name&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">Upload artifact&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">uses&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">actions/upload-pages-artifact@v2&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">with&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">path&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">./public&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">deploy&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">environment&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">name&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">github-pages&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">url&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">${{ steps.deployment.outputs.page_url }}&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">runs-on&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">ubuntu-latest&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">needs&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">build&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">steps&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>- &lt;span class="nt">name&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">Deploy to GitHub Pages&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">id&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">deployment&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">uses&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">actions/deploy-pages@v2&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Durch diese Einrichtung wird eine automatisierte Pipeline erstellt, bei der allein die Aktion &amp;ldquo;Einen Artikel in Markdown schreiben und zu GitHub pushen&amp;rdquo; ausreicht, um die neueste Website in wenigen Minuten in der Produktionsumgebung zu veröffentlichen.&lt;/p>
&lt;hr>
&lt;h2 id="6-seo-und-betriebliche-vorteile-nach-der-migration">6. SEO und betriebliche Vorteile nach der Migration
&lt;/h2>&lt;p>Website-Betreiber, die die Migration von WordPress zu Hugo abgeschlossen haben, erleben in den meisten Fällen die folgenden drei signifikanten Vorteile.&lt;/p>
&lt;h3 id="61-drastische-verbesserung-der-website-geschwindigkeit-und-core-web-vitals">6.1 Drastische Verbesserung der Website-Geschwindigkeit und Core Web Vitals
&lt;/h3>&lt;p>Durch den Wegfall von Datenbankabfragen und serverseitigem Rendering wird die Ladezeit von Seiten auf Millisekunden reduziert. Dies führt direkt zu einer deutlichen Verbesserung der &amp;ldquo;Core Web Vitals&amp;rdquo;-Werte (LCP, FID/INP, CLS), die Google als Ranking-Faktoren verwendet. Ein Rückgang der Absprungrate der Nutzer und eine Verbesserung der SEO-Bewertung sind zu erwarten.&lt;/p>
&lt;h3 id="62-befreiung-von-sicherheitsbedrohungen">6.2 Befreiung von Sicherheitsbedrohungen
&lt;/h3>&lt;p>Da WordPress weltweit weit verbreitet ist, ist es ein ständiges Ziel von Angriffen. Es bestehen immer Risiken wie Verfälschungen durch das Ausnutzen von Plugin-Schwachstellen oder das Knacken von Logins durch Brute-Force-Angriffe.
Auf einer mit Hugo generierten statischen Website gibt es jedoch weder eine Datenbank noch eine PHP-Umgebung oder gar einen Verwaltungsbildschirm (Login-Formular). Hacker haben keine Möglichkeit, in den Server einzudringen und die Datenbank umzuschreiben, sodass das Sicherheitsrisiko extrem nahe an Null herankommt.&lt;/p>
&lt;h3 id="63-wartungsfreier-betrieb">6.3 Wartungsfreier Betrieb
&lt;/h3>&lt;p>Der Betrieb von WordPress erfordert ständige Wartungsarbeiten, einschließlich Updates des Core-Systems, Plugin-Aktualisierungen und das Nachverfolgen von PHP-Versionen. Sie müssen immer die Angst haben, dass die Website aufgrund von Kompatibilitätsproblemen zusammenbricht.
Bei Hugo müssen Updates des Tools selbst nur bei Bedarf durchgeführt werden, und da der Code der Website selbst aus einer Reihe unabhängiger Textdateien besteht, herrscht das überwältigende Gefühl der Sicherheit, dass &amp;ldquo;es nicht kaputt geht, selbst wenn man es in Ruhe lässt&amp;rdquo;.&lt;/p>
&lt;hr>
&lt;h2 id="7-zusammenfassung">7. Zusammenfassung
&lt;/h2>&lt;p>In diesem Artikel haben wir die Migration von einem dynamischen CMS wie WordPress zu &amp;ldquo;Hugo&amp;rdquo;, einem leistungsstarken, auf der Programmiersprache Go basierenden Static Site Generator, im Detail erläutert – von den Unterschieden in der technischen Architektur über den mathematischen Leistungsnachweis bis hin zu konkreten Migrationsschritten.&lt;/p>
&lt;p>Der Umstieg auf einen Static Site Generator erfordert zunächst eine gewisse Lernkurve (Git-Operationen, Markdown-Syntax, Ausführen von CLI-Befehlen über das Terminal, Verständnis der Spezifikationen der Template-Engine usw.), bringt aber im Gegenzug &amp;ldquo;überwältigende Anzeigegeschwindigkeit&amp;rdquo;, &amp;ldquo;robuste Sicherheit&amp;rdquo; und &amp;ldquo;wartungsfreien&amp;rdquo; Betrieb, was diese Mühe mehr als aufwiegt.&lt;/p>
&lt;p>Wenn Ihre Website keine häufigen Designänderungen oder komplexe dynamische Verarbeitung (wie Funktionen nur für Mitglieder oder erweiterte E-Commerce-Funktionen) erfordert und der Hauptzweck die Informationsverbreitung ist (Blogs, Medien, Unternehmenswebsites), dann ist die Migration zu Hugo eine der effektivsten technischen Investitionen. Wir hoffen, dass Sie diesen Artikel als Referenz nutzen, um den ersten Schritt in Richtung der nächsten Generation des Website-Managements mit Hugo zu machen.&lt;/p></description></item></channel></rss>