A Jekyll favicon can build successfully and still break when the site uses a baseurl: the asset lands in a nested path, but the HTML points to the domain root. Keep source files in a static directory, generate URLs through Jekyll, and inspect the built output before publishing.
Prerequisites
- A Jekyll project with editable layouts or includes.
- A square SVG, an ICO fallback, and optionally a 180×180 PNG. Mzu favicondl can create these from one image.
- Local access to
bundle exec jekyll build.
Add a Jekyll favicon in five steps
Create a permanent source folder
Add favicon.svg, favicon.ico, and apple-touch-icon.png to assets/images/. Never edit _site/; Jekyll recreates that directory during the next build.
Add links to the document head
Open your theme’s _includes/head.html and insert these tags before its closing head element. If the theme has no include, place them directly in _layouts/default.html. Confirm that the layout still calls {% include head.html %}.
<link rel='icon' type='image/svg+xml' href='{{ '/assets/images/favicon.svg' | relative_url }}'>
<link rel='icon' sizes='16x16 32x32 48x48' href='{{ '/assets/images/favicon.ico' | relative_url }}'>
<link rel='apple-touch-icon' sizes='180x180' href='{{ '/assets/images/apple-touch-icon.png' | relative_url }}'>
The HTML specification defines rel='icon' for an icon resource. Keeping the links in the head lets the browser discover them while parsing the page.
Generate baseurl-aware URLs
Set baseurl in _config.yml to match the deployment path. Then run every icon path through Jekyll’s relative_url filter. It prefixes the configured base path, so the template works at the domain root and under a project subpath. Do not hard-code href='/assets/images/favicon.svg', because it ignores that subpath.
Build and inspect the generated site
Run the build and local server:
bundle exec jekyll build
bundle exec jekyll serve
Open _site/index.html and confirm that each link includes the expected base path. Check that the three files exist under _site/assets/images/. For the preview, use the baseurl-aware URL printed by Jekyll instead of assuming the site starts at /.
Verify the deployed response
After publishing, inspect the page source and request an icon URL directly. The page must reference the deployed path, and the icon request must not return a 404. If the old mark persists, rename the file or add a query such as favicon.svg?v=2. The favicon troubleshooting guide covers cache-specific checks.
Common pitfalls
- Editing generated files: changes in
_site/ disappear on the next build. - Ignoring
baseurl: root-relative paths can request the icon from the wrong location. - Keeping duplicate links: a theme icon and your custom icon can compete. Remove the unwanted link from the rendered head.
- Placing markup in the body: move the links into the head include or layout.
Conclusion
With assets under assets/, links in your reusable head template, and URLs generated by relative_url, your Jekyll favicon moves cleanly from source to production. For format choices and broader tag examples, read the HTML favicon guide.
Jekyll favicon은 사이트에서 baseurl을 사용하는 경우 빌드가 성공하더라도 문제가 생길 수 있습니다. 에셋은 중첩 경로에 배치되지만 HTML은 도메인 루트를 가리키기 때문입니다. 정적 디렉터리에 소스 파일을 두고 Jekyll로 URL을 생성한 다음, 게시하기 전에 빌드 결과를 확인하세요.
준비 사항
- layout 또는 include를 수정할 수 있는 Jekyll 프로젝트.
- 정사각형 SVG, ICO fallback, 선택적으로 180×180 PNG. Mzu favicondl을 사용하면 하나의 이미지로 이 파일들을 만들 수 있습니다.
bundle exec jekyll build를 로컬에서 실행할 수 있어야 합니다.
다섯 단계로 Jekyll favicon 추가하기
영구 소스 폴더 만들기
favicon.svg, favicon.ico, apple-touch-icon.png을 assets/images/에 추가합니다. _site/는 직접 수정하지 않습니다. Jekyll이 다음 빌드에서 해당 디렉터리를 다시 생성하기 때문입니다.
문서 head에 링크 추가하기
테마의 _includes/head.html을 열고 닫는 head 요소 바로 앞에 다음 태그를 삽입합니다. 테마에 해당 include 파일이 없다면 _layouts/default.html에 직접 넣습니다. 레이아웃에서 {% include head.html %}을 계속 호출하는지도 확인합니다.
<link rel='icon' type='image/svg+xml' href='{{ '/assets/images/favicon.svg' | relative_url }}'>
<link rel='icon' sizes='16x16 32x32 48x48' href='{{ '/assets/images/favicon.ico' | relative_url }}'>
<link rel='apple-touch-icon' sizes='180x180' href='{{ '/assets/images/apple-touch-icon.png' | relative_url }}'>
HTML 명세는 rel='icon'을 아이콘 리소스를 위해 정의합니다. 이 링크를 head 안에 두면 브라우저가 페이지를 파싱하는 동안 favicon을 발견할 수 있습니다.
baseurl을 반영한 URL 생성하기
_config.yml에서 baseurl을 배포 경로와 일치하도록 설정합니다. 그런 다음 모든 아이콘 경로에 Jekyll의 relative_url 필터를 적용합니다. 이 필터는 설정된 base path를 경로 앞에 붙이므로, 하나의 템플릿을 도메인 루트와 프로젝트 하위 경로 모두에서 사용할 수 있습니다. href='/assets/images/favicon.svg'처럼 경로를 직접 지정하지 않습니다. 하위 경로를 무시하기 때문입니다.
빌드하고 생성된 사이트 검사하기
다음과 같이 빌드하고 로컬 서버를 실행합니다.
bundle exec jekyll build
bundle exec jekyll serve
_site/index.html을 열어 각 링크에 예상한 base path가 포함되어 있는지 확인합니다. _site/assets/images/ 아래에 세 파일이 존재하는지 확인합니다. 미리보기할 때는 사이트가 /에서 시작한다고 가정하지 말고, Jekyll이 출력한 baseurl 반영 URL을 사용합니다.
배포된 응답 검증하기
게시 후 페이지 소스를 확인하고 아이콘 URL을 직접 요청합니다. 페이지가 배포된 경로를 참조해야 하며, 아이콘 요청이 404를 반환하지 않아야 합니다. 이전 아이콘이 계속 표시된다면 파일 이름을 변경하거나 favicon.svg?v=2처럼 query string을 추가합니다. favicon 문제 해결 가이드에는 캐시 관련 점검 항목이 정리되어 있습니다.
흔한 실수
- 생성된 파일 직접 수정:
_site/에 적용한 변경은 다음 build에서 사라집니다. baseurl 무시: root-relative path를 사용하면 icon이 잘못된 위치에서 요청될 수 있습니다.- 중복 link 유지: theme icon과 사용자 정의 icon이 서로 경쟁할 수 있습니다. 렌더링된 head에서 원치 않는 link를 제거하세요.
- markup을 body에 배치: link를 head include 또는 layout 안으로 옮기세요.
결론
assets/ 아래에 assets를 배치하고, 재사용 가능한 head template에 link를 넣고, relative_url로 URL을 생성하면 Jekyll favicon을 source에서 production까지 문제없이 옮길 수 있습니다. format 선택과 더 폭넓은 tag 예제는 HTML favicon 가이드를 참고하세요.
Guía del favicon en Jekyll: añade iconos sin romper el baseurl
Un favicon de Jekyll puede compilarse correctamente y aun así fallar cuando el sitio usa un baseurl: el recurso termina en una ruta anidada, pero el HTML apunta a la raíz del dominio. Mantén los archivos fuente en un directorio estático, genera las URL con Jekyll y revisa el output compilado antes de publicar.
Requisitos previos
- Un proyecto Jekyll con
layouts o includes que puedas editar. - Un SVG cuadrado, un ICO como fallback y, opcionalmente, un PNG de 180×180. Mzu favicondl puede crearlos a partir de una sola imagen.
- Acceso local para ejecutar
bundle exec jekyll build.
Añade un favicon a Jekyll en cinco pasos
Crea una carpeta de origen permanente
Añade favicon.svg, favicon.ico y apple-touch-icon.png a assets/images/. No edites nunca _site/; Jekyll vuelve a crear ese directorio durante la siguiente compilación.
Añade los enlaces al head del documento
Abre _includes/head.html de tu tema e inserta estas etiquetas antes de que se cierre el elemento head. Si el tema no tiene ese include, colócalas directamente en _layouts/default.html. Comprueba que el layout siga invocando {% include head.html %}.
<link rel='icon' type='image/svg+xml' href='{{ '/assets/images/favicon.svg' | relative_url }}'>
<link rel='icon' sizes='16x16 32x32 48x48' href='{{ '/assets/images/favicon.ico' | relative_url }}'>
<link rel='apple-touch-icon' sizes='180x180' href='{{ '/assets/images/apple-touch-icon.png' | relative_url }}'>
La especificación de HTML define rel='icon' para un recurso de icono. Mantener los enlaces en el head permite que el navegador los descubra mientras analiza la página.
Genera URLs compatibles con baseurl
Establece baseurl en _config.yml para que coincida con la ruta de despliegue. Después, haz pasar todas las rutas de los iconos por el filtro relative_url de Jekyll. Este añade como prefijo la ruta base configurada, de modo que la plantilla funciona tanto en la raíz del dominio como bajo una subruta del proyecto. No codifiques de forma fija href='/assets/images/favicon.svg', porque así se ignora esa subruta.
Compila e inspecciona el sitio generado
Ejecuta la compilación y el servidor local:
bundle exec jekyll build
bundle exec jekyll serve
Abre _site/index.html y comprueba que cada enlace incluya la ruta base prevista. Comprueba que los tres archivos existan en _site/assets/images/. Para la previsualización, usa la URL compatible con baseurl que muestra Jekyll en lugar de suponer que el sitio empieza en /.
Verifica la respuesta del despliegue
Tras publicar, inspecciona el código fuente de la página y solicita directamente una URL de icono. La página debe hacer referencia a la ruta desplegada, y la solicitud del icono no debe devolver un 404. Si persiste el icono anterior, renombra el archivo o añade un parámetro de consulta como favicon.svg?v=2. La guía para solucionar problemas del favicon cubre las comprobaciones específicas de la caché.
Problemas habituales
- Editar archivos generados: los cambios en
_site/ desaparecen en la siguiente compilación. - Ignorar
baseurl: las rutas relativas a la raíz pueden solicitar el icono desde una ubicación incorrecta. - Mantener enlaces duplicados: el icono del theme y el icono personalizado pueden competir. Elimina del
head final el enlace que no quieras incluir. - Colocar el marcado en el body: mueve los enlaces al include o layout del
head.
Conclusión
Con los assets en assets/, los enlaces en tu plantilla de head reutilizable y las URL generadas por relative_url, tu favicon de Jekyll pasará de source a production sin problemas. Para elegir el formato y consultar más ejemplos de etiquetas, lee la guía de favicon en HTML.