Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

175
Vistas
how to download static file in gatsby js

I have a website with Gatsby.JS
I want to when click download button, download one static pdf file.

<button>
    <a download={`../../file.pdf`}> İndir</a>
</button>

this ../../file.pdf is path of static folder.
Above code my downloadable code.

But this is not work. How can i fix.?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The download attribute, summarizing a lot is just a way to set the name of the downloadable element but it's the href attribute the one that must point to the item you want to download.

This should work:

<a download={`Some Fancy Name`} href={`../../file.pdf`}>İndir</a>

Double-check the ../../file.pdf path to ensure that is valid or that the file.pdf belongs to that route.

The static folder replicates its internal structure to the public (/public) one when the site builds. So, a structure like: /static/file.pdf should be pointed as:

<a download={`Some Fancy Name`} href={`/file.pdf`}>İndir</a>

Since the static folder becomes the "root", the level 0.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda