Hugo构建github个人博客,主题无法渲染
场景:
Failed to find a valid digest in the 'integrity' attribute for resource '<xxx>.css' with computed SHA-256 integrity '9J1myq6eoP1D8h8p5xqNPihFF+13Dyqob6ASlTrTye8='. The resource has been blocked.
在访问github page的时候,发现个人博客(hugo框架构建)没有主题效果只有文字,打开F12你会看到控制台有类似如上报错
原因:
这是由于你的博客项目中/assets/css/stylesheet.xxx.css样式文件的 SHA-256 校验值与你所使用的主题 integrity 属性中的值不匹配,导致浏览器阻止加载样式文件,因此github page只正常展示了文字,而没有展示主题效果。
解决方案:
假设你的主题是PaperMod,那么你需要在<project>/themes/PaperMod/layouts/partials目录下找到head.html文件,将integrity="{{ $stylesheet.Data.Integrity }}" 这么一句代码,把它改为 integrity="",修改如下
<!--<link crossorigin="anonymous" href="{{ $stylesheet.RelPermalink }}" integrity="{{ $stylesheet.Data.Integrity }}" rel="preload stylesheet" as="style">-->
<link crossorigin="anonymous" href="{{ $stylesheet.RelPermalink }}" integrity="" rel="preload stylesheet" as="style">重新部署,再次访问github page,主题即可成功渲染了
参考:
https://smc.im/post/resolve-integrity-error-in-hugo/
 
                    
                     
                    
                 
                    
                
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号