You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何修改Github Pages Architect主题下载按钮的跳转路径与显示文本

Jekyll Architect主题自定义下载按钮操作指南

配置说明

默认配置下Architect主题的下载按钮会自动关联站点对应仓库的gh-pages分支下载地址,按钮文本为固定值,仅靠默认的show_downloads参数无法自定义,你当前的初始_config.yml配置为:

theme: jekyll-theme-architect
show_downloads: true

相关按钮效果参考:
按钮效果示意图

修改步骤

方案一:硬编码修改(快速生效)

  • 在站点根目录新建_layouts文件夹
  • 在_layouts文件夹下新建名为default.html的文件,粘贴主题默认布局代码,找到下载按钮对应的代码段,默认内容如下:
{% if site.show_downloads %}
  <section id="downloads">
    <a href="{{ site.github.zip_url }}" class="zip">Download as zip</a>
    <a href="{{ site.github.tar_url }}" class="tar">Download as tar.gz</a>
    <a href="{{ site.github.repository_url }}" class="button">View on GitHub</a>
  </section>
{% endif %}
  • 直接替换<a>标签的href属性值为你需要的目标下载路径,修改标签中间的文本为你想要的按钮显示内容即可,修改后示例代码:
{% if site.show_downloads %}
  <section id="downloads">
    <a href="https://github.com/你的用户名/你的仓库名/archive/refs/heads/main.zip" class="zip">下载主分支Zip包</a>
    <a href="https://github.com/你的用户名/你的仓库名/archive/refs/heads/main.tar.gz" class="tar">下载主分支Tar包</a>
    <a href="{{ site.github.repository_url }}" class="button">访问GitHub仓库</a>
  </section>
{% endif %}

方案二:新增配置项(便于后续维护)

如果希望后续直接通过_config.yml修改参数,不需要调整布局代码,可以按以下操作:

  • 在_config.yml中新增自定义配置参数:
theme: jekyll-theme-architect
show_downloads: true
# 新增自定义下载配置
custom_zip_url: "你的Zip包下载完整路径"
custom_zip_text: "Zip包下载"
custom_tar_url: "你的Tar.gz包下载完整路径"
custom_tar_text: "Tar.gz包下载"
  • 修改刚才新建的_layouts/default.html中的下载按钮代码段为:
{% if site.show_downloads %}
  <section id="downloads">
    <a href="{{ site.custom_zip_url }}" class="zip">{{ site.custom_zip_text }}</a>
    <a href="{{ site.custom_tar_url }}" class="tar">{{ site.custom_tar_text }}</a>
    <a href="{{ site.github.repository_url }}" class="button">访问GitHub仓库</a>
  </section>
{% endif %}

注意:修改完成后重新构建站点即可生效,本地预览时需要重启Jekyll服务

内容的提问来源于stack exchange,提问作者TheC0mpu1er

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.02 17:15:02