问题描述
好吧,我已经建立了自己的Gatsby网站,并且遇到了Image问题.它会在图像文件名的末尾生成一个哈希.
Well, I have build my Gatsby website and facing a problem with Image. It's generating a hash at the end of image file name.
/static/imagename-719331c87d42041b22e62a63d9af6e69.webp
/static/imagename-719331c87d42041b22e62a63d9af6e69.webp
代码:
import Img1 from '../images/image.webp';
.........
......
...........
<picture>
<source srcSet={Img1} />
<img src={Img1} alt="alt" loading="lazy" height="500px" width="800px"/>
</picture>
我如何克服这个问题.
第二件事是:我没有将我的公用文件夹部署到netlify.是否有必要将公用文件夹推送到github?这样netlify会得到吗?每次我将网站推送到github并netlify重新上传所有文件时.
Second thing is: i am not deploying my public folder to netlify. Is it necessary to push the public folder to github? so netlify will get it? Each time i push my site to github and netlify reupload the all files.
推荐答案
如果图像的重量小于10,000字节,则Gatsby将返回数据URI而不是路径.根据静态文件夹的文档:
If your image's weight is less than 10,000 bytes, Gatsby will return a Data URI instead of the path. According to the documentation of the static folder:
尝试将其更改为另一种格式.
Try changing it to another format.
当然不是.您不应发布您的/public
文件夹,因为该文件夹将由Netlify(或您的部署系统)在每个构建/部署中创建.这将浪费MB.
Of course not. You should not publish your /public
folder since it will be created by Netlify (or your deploy system) in each build/deploy. It would be a waste of MB.
这篇关于如何从图像URl Gatsby中删除哈希的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!