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

pa11y-ci如何指定默认HTML报告文件名?怎么在配置中添加sitemap?

Pa11y-ci 配置问题解决方案

1. 指定HTML报告文件名为myreport.html

你可以任选以下两种方式实现:

  • 命令行重定向方式:直接在原有执行命令后添加输出重定向规则即可,修改后的命令如下:
pa11y-ci --sitemap https://oursite.co.uk/sitemaps/sitemap.xml > myreport.html
  • 配置文件指定方式:在你的配置文件中新增reporterOptions字段,完整配置参考如下:
{
    "defaults": {
        "reporters": [
            "pa11y-reporter-html"
        ],
        "reporterOptions": {
            "html": {
                "fileName": "myreport.html"
            }
        },
        "timeout": 10000,
        "standard": "WCAG2A",
        "viewport": {
            "width": 800,
            "height": 600
        }
    }
}

2. Sitemap写入配置文件的正确方法

你之前配置不生效的原因有两点:一是sitemap键名末尾多写了多余的英文冒号,二是sitemap属于和defaults平级的顶级配置项,不能放在defaults字段内部。
正确的完整配置如下:

{
    "sitemap": "https://oursite.co.uk/sitemaps/sitemap.xml",
    "defaults": {
        "reporters": [
            "pa11y-reporter-html"
        ],
        "reporterOptions": {
            "html": {
                "fileName": "myreport.html"
            }
        },
        "timeout": 10000,
        "standard": "WCAG2A",
        "viewport": {
            "width": 800,
            "height": 600
        }
    }
}

修改配置后,直接执行pa11y-ci命令即可,无需额外添加--sitemap参数。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.24 05:15:00