大网数据广告活动
网站运营与故障问答

Is there any point to use absolute URLs for asset files like css/js for SEO optimization?

· 52CE 我爱测

Should I use absolute paths for CSS or JS resources in <link and <script tags? Is there any reason? Some SEO optimization say fix it, should I do it for any reason? I do not know why, if everything is working fine? <link rel="sty…

问题原文

原帖链接 · Mohammad Hossein Fattahizadeh · CC BY-SA 4.0

Should I use absolute paths for CSS or JS resources in <link and <script tags?

Is there any reason?

Some SEO optimization say fix it, should I do it for any reason?

I do not know why, if everything is working fine?

<link rel="stylesheet" href="/css/main_rtl.css?v=5e6e47e9">
<script src="/lib/js/frameworks.min.js?v=5e6e47e9"></script>

Vs

<link rel="stylesheet" href="https://sample.com/css/main_rtl.css?v=5e6e47e9">
<script src="https://example.com/lib/js/frameworks.min.js?v=5e6e47e9"></script>

Is there any SEO-related point?

Shorter version is smaller HTML at least.

  • each page has canonical
  • domain only serve https version(http redirect to https)

已采纳解答

原帖链接 · Don King · CC BY-SA 4.0

If your website is available on both http and https I definitely recommend using relative path and not absolute. Otherwise I cant really see any specific difference.

The SEO optimization services might recommend you to use absolute paths because it could in theory create some issues for them if you use relative path, but I would ignore that myself because I don't think it matter much for Google and other large indexers.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2019-10-07)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。