# 从主题资产SCSS获取网址

**URL:** https://meta.discourse.org/t/get-the-url-from-theme-asset-scss/263856
**Category:** Development
**Created:** [2023年五月4日 16:47 UTC](https://meta.discourse.org/t/get-the-url-from-theme-asset-scss/263856 "2023-05-04T16:47:56Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![exo-consulting](https://avatars.discourse-cdn.com/v4/letter/e/977dab/32.png) [@exo-consulting](https://meta.discourse.org/u/exo-consulting)
#### Post date: [2023年五月4日 16:47 UTC](https://meta.discourse.org/t/get-the-url-from-theme-asset-scss/263856/1 "2023-05-04T16:47:56Z")

</div>

你好！  
如何获取上传资源的 URL？  
如果我想在 CSS 或 HTML 中使用此图片？  
例如在我的

```plaintext
<img src=" 链接是什么 "/>
.logo {
     background-image: url( 链接是什么 );
}

```

 ![image](https://global.discourse-cdn.com/meta/original/4X/c/d/a/cda685575c16292a6c4ac108abba7ce0b69993c1.png)

---

<div class="post-metadata">

### Author: ![awesomerobot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/awesomerobot/32/142900_2.png) [@awesomerobot](https://meta.discourse.org/u/awesomerobot)
#### Post date: [2023年五月4日 16:56 UTC](https://meta.discourse.org/t/get-the-url-from-theme-asset-scss/263856/2 "2023-05-04T16:56:38Z")

</div>

这里有一些指导：[Include assets (e.g. images, fonts) in themes and components](https://meta.discourse.org/t/include-assets-e-g-images-fonts-in-themes-and-components/62459)

所以，在你的情况下，你会想这样做：

```scss
.logo {
     background-image: url($essential-logo);
}

```

你无法直接在 HTML 中访问资源，所以如果你不知道如何使用 JavaScript 或 Handlebars，你可能想将其用作 CSS 背景图像（这在上面我分享的链接中也有介绍）。

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [2023年六月8日 05:56 UTC](https://meta.discourse.org/t/get-the-url-from-theme-asset-scss/263856/3 "2023-06-08T05:56:04Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
