Your Hugo site builds cleanly, yet its browser tab still shows a generic page icon. That usually means the icon file sits outside Hugo’s published asset path or the generated HTML never references it. A reliable Hugo favicon setup separates assets from templates: static/ publishes the files, while a layout partial adds the browser-facing <link> elements.
Prerequisites
You need an existing Hugo site, a square logo or icon, and access to its layouts. If your master file is PNG or SVG, use Mzu favicondl to prepare an ICO fallback, and keep the original artwork at its highest available resolution.
- An existing Hugo project
- A square SVG and ICO icon
- Access to your project’s and theme’s layouts
Add a Hugo favicon in four steps
-
Create the published files. Convert your artwork to
favicon.svg and favicon.ico, then place both in Hugo’s root-level static/ directory:
static/
favicon.svg
favicon.ico
Files in static/ are copied as-is, so Hugo publishes them at the site root.
-
Create a reusable partial. Add
layouts/partials/head/favicon.html with:
<link rel='icon' href='{{ "favicon.ico" | relURL }}' sizes='any'>
<link rel='icon' href='{{ "favicon.svg" | relURL }}' type='image/svg+xml'>
The HTML specification defines the icon link relation. We use relURL so the generated path follows Hugo’s base path instead of assuming the site lives at the domain root.
-
Render the partial in
<head>. Search your project and active theme for the layout containing the document head. Add this line immediately before its closing head tag:
<head>
...
{{ partial "head/favicon.html" . }}
</head>
If the file belongs to a theme, copy it into your project’s equivalent layouts/ path first; otherwise, a theme update can overwrite the edit. If the theme already calls a favicon partial, edit that partial instead of adding a second one.
-
Build, preview, and inspect. Run:
hugo
hugo server
Open the local site and inspect the page head in browser developer tools. Confirm that the generated icon URLs return 200, and check that public/favicon.svg and public/favicon.ico exist after the production build. For a wider comparison of framework patterns, see the static site generator favicon guide.
Common pitfalls
- Placing the icon only in
assets/. That directory is for Hugo-managed resources. Put unchanged public files in static/, or process them through Hugo’s resource pipeline.
- Hard-coding
/favicon.svg. This breaks sites deployed under a subpath. Build the URL with relURL.
- Editing only a theme file. Theme upgrades may replace it. Keep the override in your project whenever possible.
- Expecting an immediate refresh. Browsers can cache icon URLs. Follow the favicon troubleshooting checklist if the live page still uses the old icon.
Confirm the final result
Your Hugo favicon is ready when the generated head contains both link elements, every referenced file returns successfully, and the browser tab shows the intended mark. Keep the source artwork separate from the generated files so future updates remain predictable.
Hugo サイトは正常にビルドできるのに、ブラウザーのタブにはまだ汎用のページアイコンしか表示されません。多くの場合、アイコンファイルが Hugo の公開対象である asset path の外にあるか、生成された HTML がそれを参照していないことが原因です。安定した Hugo favicon のセットアップでは、asset と template を分離します。static/ がファイルを公開し、layout partial がブラウザーで認識される <link> 要素を追加します。
前提条件
既存の Hugo サイト、正方形の logo または icon、そして layouts へのアクセス権が必要です。master file が PNG または SVG なら、ICO fallback を準備するために Mzu favicondl を使い、元の artwork は利用可能な最高解像度で保持してください。
- 既存の Hugo project
- 正方形の SVG icon と ICO icon
- project と theme の layouts へのアクセス権
4ステップで Hugo favicon を追加する
-
公開用ファイルを作成します。 元の artwork を
favicon.svg と favicon.ico に変換し、両方を Hugo のルートレベルにある static/ directory に配置します。
static/
favicon.svg
favicon.ico
static/ 内のファイルはそのままコピーされるため、Hugo はそれらを site root に公開します。
-
再利用できる partial を作成します。
layouts/partials/head/favicon.html を追加して、次の内容を記述します。
<link rel='icon' href='{{ "favicon.ico" | relURL }}' sizes='any'>
<link rel='icon' href='{{ "favicon.svg" | relURL }}' type='image/svg+xml'>
HTML 仕様では icon link relation が定義されています。relURL を使うことで、生成される path はサイトCrunchがドメインのルートにあると仮定せず、Hugo の base path に従います。
-
<head> 内で partial をレンダリングします。 project と使用中の theme を検索し、document head を含む layout を探してください。その head の閉じタグの直前に、次の行を追加します。
<head>
...
{{ partial "head/favicon.html" . }}
</head>
対象の layout ファイルが theme に属する場合は、まず project 側の対応する layouts/ path にコピーしてください。そうしないと、theme の更新で変更が上書きされる可能性があります。theme がすでに favicon partial を呼び出している場合は、2 つ目を追加せず、その partial を編集してください。
-
ビルド、プレビュー、検証します。 次を実行します。
hugo
hugo server
ローカルサイトを開き、browser developer tools で page head を確認します。生成された icon URL が 200 を返すことを確認し、production build の後に public/favicon.svg と public/favicon.ico が存在するか確認してください。より広範な framework pattern の比較については、static site generator favicon guide を参照してください。
よくある落とし穴
- favicon を
assets/ にだけ配置すること。 このディレクトリは Hugo が管理するリソース用です。変更を加えずに公開するファイルは static/ に置くか、Hugo の resource pipeline で処理してください。
/favicon.svg をハードコードすること。 subpath 配下にデプロイしたサイトだと動かなくなるためです。URL は relURL で構築してください。
- テーマのファイルだけを編集すること。 テーマのアップグレードでファイルが置き換えられる可能性があります。可能な限り、プロジェクト側で上書き内容を保持してください。
- すぐに反映されることを期待すること。 ブラウザは favicon の URL をキャッシュすることがあります。公開中のページで古い favicon が表示されている場合は、favicon のトラブルシューティングチェックリスト に従ってください。
最終結果を確認する
生成された head に 2 つの link 要素が含まれ、参照されているすべてのファイルが正常に取得でき、ブラウザのタブに意図したマークが表示されていれば、Hugo の favicon の設定は完了です。将来の更新を予測可能にするため、元のアートワークは生成されたファイルとは分けて管理してください。
Hugo 사이트는 정상적으로 빌드되지만 브라우저 탭에는 여전히 기본 페이지 아이콘만 표시됩니다. 보통 아이콘 파일이 Hugo의 게시 asset 경로 밖에 있거나 생성된 HTML이 해당 파일을 참조하지 않기 때문입니다. 안정적인 Hugo favicon 설정은 asset과 template을 분리합니다. static/가 파일을 게시하고, layout partial이 브라우저가 참조할 <link> 요소를 추가합니다.
필수 조건
기존 Hugo 사이트, 정사각형 로고 또는 아이콘, layouts 접근 권한이 필요합니다. master file이 PNG 또는 SVG 형식이라면 Mzu favicondl로 ICO fallback을 준비하고, 원본 그래픽은 확보할 수 있는 가장 높은 해상도로 보관하세요.
- 기존 Hugo 프로젝트
- 정사각형 SVG와 ICO 아이콘
- 프로젝트와 theme의 layouts 접근 권한
네 단계로 Hugo favicon 추가하기
-
게시 파일을 만듭니다. 원본 그래픽을
favicon.svg와 favicon.ico로 변환한 다음, 두 파일을 Hugo의 최상위 static/ 디렉터리에 배치하세요:
static/
favicon.svg
favicon.ico
static/의 파일은 그대로 복사되므로 Hugo가 사이트 루트에 게시합니다.
-
재사용 가능한 partial을 만듭니다.
layouts/partials/head/favicon.html 파일을 다음 내용으로 추가합니다:
<link rel='icon' href='{{ "favicon.ico" | relURL }}' sizes='any'>
<link rel='icon' href='{{ "favicon.svg" | relURL }}' type='image/svg+xml'>
HTML 명세는 icon link relation을 정의합니다. relURL을 사용하면 사이트가 domain root에 있다고 가정하지 않고, 생성되는 경로가 Hugo의 base path를 따릅니다.
-
<head> 안에 partial을 렌더링합니다. 프로젝트와 사용 중인 theme에서 document head를 포함한 layout을 찾으세요. head의 닫는 태그 바로 앞에 다음 줄을 추가합니다:
<head>
...
{{ partial "head/favicon.html" . }}
</head>
수정할 파일이 theme에 속한다면 먼저 프로젝트의 동등한 layouts/ 경로로 복사하세요. 그렇지 않으면 theme 업데이트 과정에서 수정이 덮어써질 수 있습니다. theme이 이미 favicon partial을 호출한다면 두 번째 partial을 추가하지 말고 기존 partial을 수정하세요.
-
빌드하고 미리 본 뒤 점검합니다. 다음 명령을 실행합니다:
hugo
hugo server
로컬 사이트를 열고 browser developer tools에서 페이지 head를 점검하세요. 생성된 아이콘 URL이 200을 반환하는지 확인하고, production build 후 public/favicon.svg와 public/favicon.ico가 존재하는지 확인합니다. framework 패턴을 더 폭�게 비교하려면 static site generator favicon guide를 참고하세요.
흔히 빠지기 쉬운 실수
- 아이콘을
assets/에만 배치하는 것. 이 디렉터리는 Hugo가 관리하는 리소스를 위한 곳입니다. 변경 없이 제공할 공개 파일은 static/에 넣거나 Hugo의 resource pipeline을 통해 처리해야 합니다.
/favicon.svg 경로를 직접 작성하는 것. 사이트를 subpath에 배포하면 문제가 발생합니다. relURL로 URL을 생성하세요.
- theme 파일만 수정하는 것. theme을 업그레이드하면 해당 파일이 대체될 수 있습니다. 가능하면 항상 프로젝트 안에서 override를 유지하세요.
- 즉시 반영되기를 기대하는 것. 브라우저가 아이콘 URL을 cache할 수 있습니다. 실제 페이지에 여전히 기존 아이콘이 표시된다면 favicon 문제 해결 체크리스트를 따르세요.
최종 결과 확인
생성된 head에 두 개의 link 요소가 모두 포함되고, 참조된 모든 파일이 정상적으로 응답하며, 브라우저 탭에 의도한 아이콘이 표시된다면 Hugo favicon 설정은 완료된 것입니다. 향후 업데이트를 예측하기 쉽게 하려면 원본 아트워크와 생성된 파일을 분리해 두세요.
Tu sitio Hugo se compila sin errores, pero la pestaña de tu navegador todavía muestra un icono genérico. Normalmente, esto significa que el archivo del icono está fuera de la ruta de assets publicados de Hugo o que el HTML generado nunca lo referencia. Una configuración fiable de Hugo favicon separa los assets de las plantillas: static/ publica los archivos, mientras que un partial de layout añade los elementos <link> que utiliza el navegador.
Requisitos previos
Necesitas un sitio Hugo existente, un logo o icono cuadrado y acceso a sus layouts. Si tu archivo principal está en PNG o SVG, usa Mzu favicondl para preparar un fallback en ICO y conserva el diseño original en la mayor resolución disponible.
- Un proyecto Hugo existente
- Un icono en SVG y otro en ICO, ambos cuadrados
- Acceso a los layouts de tu proyecto y de tu tema
Añade un favicon de Hugo en cuatro pasos
-
Crea los archivos que se publicarán. Convierte tu diseño en
favicon.svg y favicon.ico y coloca ambos en el directorio static/ situado en la raíz de Hugo:
static/
favicon.svg
favicon.ico
Los archivos de static/ se copian tal cual, por lo que Hugo los publica en la raíz del sitio.
-
Crea un partial reutilizable. Añade
layouts/partials/head/favicon.html con este contenido:
<link rel='icon' href='{{ "favicon.ico" | relURL }}' sizes='any'>
<link rel='icon' href='{{ "favicon.svg" | relURL }}' type='image/svg+xml'>
La especificación HTML define la relación de enlace para iconos. Usamos relURL para que la ruta generada siga el base path de Hugo en lugar de asumir que el sitio está en la raíz del dominio.
-
Renderiza el partial en
<head>. Busca en tu proyecto y en el tema activo el layout que contiene el head del documento. Añade esta línea justo antes de su etiqueta de cierre <head>:
<head>
...
{{ partial "head/favicon.html" . }}
</head>
Si el archivo pertenece al tema, cópialo primero en la ruta layouts/ equivalente de tu proyecto; de lo contrario, una actualización del tema puede sobrescribir ese cambio. Si el tema ya invoca un partial de favicon, edita ese partial en lugar de añadir un segundo.
-
Compila, previsualiza e inspecciona. Ejecuta:
hugo
hugo server
Abre el sitio local e inspecciona el head de la página en las herramientas de desarrollo del navegador. Comprueba que las URLs de los iconos generados devuelven 200 y verifica que public/favicon.svg y public/favicon.ico existan después de la compilación de producción. Para una comparación más amplia de patrones entre frameworks, consulta la guía sobre favicon en static site generators.
Errores comunes
- Colocar el icono únicamente en
assets/. Ese directorio está destinado a los recursos gestionados por Hugo. Coloca los archivos públicos sin modificar en static/ o procésalos mediante el pipeline de recursos de Hugo.
- Hardcodear
/favicon.svg. Esto rompe el funcionamiento en sitios desplegados bajo un subpath. Construye la URL con relURL.
- Editar únicamente un archivo del theme. Una actualización del theme puede reemplazarlo. Mantén la sobrescritura en tu proyecto siempre que sea posible.
- Esperar una actualización inmediata. Los navegadores pueden cachear las URLs de los iconos. Consulta la lista de comprobación para resolver problemas con el favicon si la página publicada sigue mostrando el icono anterior.
Confirma el resultado final
El favicon de Hugo estará listo cuando el head generado contenga ambos elementos link, todos los archivos referenciados devuelvan una respuesta correcta y la pestaña del navegador muestre la marca prevista. Mantén el arte original separado de los archivos generados para que las futuras actualizaciones sigan siendo predecibles.
Create a clean Hugo favicon
Prepare SVG, PNG, and ICO assets with Mzu favicondl, then add the right files to your Hugo static folder.
Try It Free →