Relative image paths
See original GitHub issueSorry but I’m completely confused by how Gridsome handles relative image paths.
Right now, the frontmatter in my markdown is image: /media/image.jpg
, and the media directory exists at the root of my project.
<div v-for="{ node } in $static.allOrganization.edges" class="sponsor__item" :key="node.id">
<g-image :src="node.logo" :alt="node.name" />
</div>
The expected values ends up in the resulting image tag, but the problem is that /media/image.jpg
doesn’t exist.
How do I get Gridsome to point to this? Alternatively, can I get g-image
to modify the the image path and point to the location instead?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:9 (3 by maintainers)
Top Results From Across the Web
HTML File Paths - W3Schools
A relative file path points to a file relative to the current page. In the following example, the file path points to a...
Read more >img tag not working with relative path in src - Stack Overflow
So when I have url like http://127.0.0.1:7777/www/ then all my relative urls working but then I use it as http://127.0.0.1:7777/www (no "/" at...
Read more >Use Relative Paths for Linked Images - Access Image FAQ
Relative path vs. absolute path possible in storing pictures? db using photos - where to keep the photos. Relative Path does not work...
Read more >HTML File Paths - Absolute and Relative File Paths - DataFlair
Learn file paths in HTML with types and examples - HTML Absolute path, relative paths-Same folder as current web-page file,Images in current folder,Folder ......
Read more >KB405775: When an image is referenced using relative paths ...
A partial path is relative to the working directory of the user or application, so that a full absolute path does not need...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@hjvedvik Is there any way to specify images relative the src/ directory in the front matter? I was hoping
image: ~/dir/image.jpg
would work, but it doesn’t seem to.@freshyill When using absolute paths, Gridsome will look for a file located somewhere in the
/static
folder. So moving the/media
folder to/static/media
should make your images work. But keep in mind that images in the/static
folder are not processed in any way, just copied to the/dist
folder when building for production.You can use relative paths like
image: ./image.jpg
to process them with the built-in image processor. The image path must be relative to the Markdown file referencing it.