question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use hashed folder names instead of filenames for images

See original GitHub issue

Summary

Since more and more people ask (https://github.com/gatsbyjs/gatsby/issues/3132, https://github.com/angeloashmore/gatsby-source-prismic/issues/40, Discord) about the image filenames and how they could remove/change the hash (Reason: SEO) I propose to move the hash out of the filename into a folder name.

Before: /static/netlify-and-discord-1c11979b664a737c4d748b895d4507a7-b4bbd.webp

After: /static/1c11979b664a737c4d748b895d4507a7-b4bbd/netlify-and-discord.webp OR /static/1c11979b664a737c4d748b895d4507a7/b4bbd/netlify-and-discord.webp

The details of the folder names / structure need to be defined as to what makes the most sense. The second structure would allow to have each image (with its different sizes) in its own folder.

Motivation

The idea came up while looking at the urls that Cloudinary serves. They do the same - and I think it’ll make the complaints of the people go away.

Cloudinary: https://cloudinary.com/blog/how_to_dynamically_create_seo_friendly_urls_for_your_site_s_images#dynamic_seo_suffixes

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:7
  • Comments:16 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
Sekhmetcommented, Oct 2, 2018

It’s time to put my Gatsby shirt on and work on some PRs again.

I will work on that.

1reaction
vinberdoncommented, Jun 29, 2018

It looks like I can just configure webpack on my own ( https://webpack.js.org/guides/caching/ ) and remove the hash settings that are built into gatsby’s version, correct?

The OP here about changing directories is not good for SEO or external (or even hard-coded internal) links at all. Many things will break and SEO will plummet. I understand that this is a niche request, so I’ll just have to find my own way to do it.

Is something like this able to be made into a plugin? Like remove-filename-hash-plugin so that I can easily implement it into any future Gatsby build?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Names of image files on a website: hashes or random strings?
I have read several questions about naming uploaded images, and people usually advise to hash image content for generating unique file name plus ......
Read more >
File Name Hashing: Creating a Hashed Directory Structure
One solution is file name hashing. Using this type of directory structure, there will be 26 possible root directories and 26² possible sub- ......
Read more >
Organizing Images or Other Files with Hashed Folder Names
This is why I decided a hashed folder naming convention would be the best approach. The folder names do not matter, just so...
Read more >
What's the purpose of the hash added to filenames in custom ...
Two reasons I can think of: what happens if you upload twice a file with the same name for different contacts? the hash...
Read more >
Why are my file names hashed when I access ... - Ask Ubuntu
Summary: The "hash" is the real name of the file. The original name (Display Name) is stored in metadata. It's not a bug...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found