Where to put pdf files

Hello!

I have a very basic site with some posts and I want to add PDF files to some posts. I tried to set the PDF files in static but when doing so, the pdf is not displayed in the browser, I get a “page not found” on the localhost with the following code in the md:
[Open PDF](static/images/pdfFile.pdf)

pdfFile.pdf is in the right folder static/images.

It does display the pdf in the browser when creating some page bundles, as in :

content
   news
      Post1folder
         pdfile.pdf
         index.md

with
[Open PDF](./pdfFile.pdf)
in the index.md file.

The only issue now is that I am setting up Decap CMS since the website is collaborative and I need to set up the configuration of the CMS which seems to take one folder for uploaded documents.

Any idea on how to set up the configuration?

Thanks!

What does that mean?

My apologies for the lack of clarity, I’ve edited the message to specify more clearly but basically, unless I add the pdf file in the bundle, I can’t get it to be displayed in the browser.

I still don’t understand what this means. Do you mean that you can’t create a link to the file in Markdown? Is there a shortcode that’s not doing what you want? Please be specific.

1 Like

I don’t know about shortcodes and haven’t set one. I am trying to set up the CMS so when others will create posts, they can add pdfs to their posts. Since it seems that when setting up the CMS I have to configure a file for uploaded documents (in this case pdf), that would be problematic if the uploaded files end up in the static folder because then they wouldn’t be displayed

We are failing to communicate.

I have no idea what this means.

The static folder will not be copied.

Use [Open PDF](/images/pdfFile.pdf)

But whatever that means your CMS i’m with @jmooring … no clue

1 Like

Thank you very much for your time and really sorry to be unable to explicit the issue more clearly.

I still get “Page not found” when clicking on Open PDF on localhost with the code [Open PDF](/images/pdfFile.pdf)

Let’s say I have a Post1 folder containing the pdf file and index.md (in content/news), upon clicking Open PDF, i get to have the pdf file displayed in the browser.

When I have the pdf file in static/images instead of in the same page bundle, I always end up with “Page not Found” upon clicking on the Open PDF link, at least with the url paths tried up to now.

For the CMS aspect, I want to set up a CMS so other users can create posts and upload those posts with the associated pdf file. I tried to see if it could be done to have the CMS create a page bundle with the pdf file and the post itself but I’m seeing one path to upload files in the config file for the CMS which makes me believe that the pdf files should be uploaded in static/images and then called from the md post so the pdf files could be displayed in the browser upon clicking the Open PDF link.

What is the baseURL in your site configuration?

Also, you are more likely to receive a prompt and accurate response if you post a link to your project’s Git repository.

See Requesting Help.

Let us see your code

Include a link to the source code repository of your project, because we really need the context of seeing your templates and partials to be able to help you. It is trivial to do a quick git clone on your repo, then run hugo server in your project, to help you out. On the other hand, recreating your code from screenshots, or sort of guessing at it, is not.

If you can’t share your repository for whatever reason, consider creating a dummy repo that you can share, which reproduces the problem you’re experiencing.

The baseURL connects to the netlify app and is as follows: baseURL = 'https://therapieinterpersonnelle.netlify.app/'

Repo of the project

I cloned your repository, added a file named “pdfFile.pdf” to the static/images directory, then placed this markdown in content/_index.md:

[Open PDF](/images/pdfFile.pdf)

Works great when I run hugo server.

Perhaps your CMS converts paths to lowercase. You might try with a file named “pdf-file.pdf” instead of “pdfFile.pdf”. In web dev in general, file names with upper case letters and spaces aren’t a great idea.

1 Like

It works indeed, I tried to pay attention for but guess I must’ve been careless. I have still to configure the CMS config but I am grateful enough for your time and answer and I realise multiplying questions on a single thread is not a good idea.

Thank to both of you for your help and have a wonderful day!

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