Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PDF always loading, never displaying. #36

Open
corei8 opened this issue Nov 10, 2022 · 7 comments
Open

PDF always loading, never displaying. #36

corei8 opened this issue Nov 10, 2022 · 7 comments

Comments

@corei8
Copy link

corei8 commented Nov 10, 2022

The initial installation did not work at all. But then I ran across this guide and I can get the shortcode to start loading the PDF, but it never actually loads it: the wheel just keeps on spinning.

@sysadmin-info
Copy link

For me it is working only locally when I run the hugo server. On my website https://sysadmin.info.pl/pl/blog/moja-praca-inzynierska/ it does not work. the repository from github is taken by netlify and I added my custom domain. I have no idea is it possible to add CORS to netlify.

@sysadmin-info
Copy link

sysadmin-info commented Mar 19, 2023

I know the solution. First of all in my case I had to change in config.toml a base URL to this
baseURL = "/"

Then in the netlify.toml (because I am using netlify) I had to define headers this way:

[build]
  command = "hugo"
  publish = "public"

[build.environment]
  HUGO_VERSION = "0.111.3"

[[headers]]
  for = "/*"
    [headers.values]
    Access-Control-Allow-Origin = "sysadmin.info.pl"

After that in my md file where I am using a shortcode I defined it this way:

{{< embed-pdf url="../../../files/document.pdf" renderPageNum="1" >}}

Because I keep the PDF file in the directory

/root dir of my site/static/files

And my md file where I am using the shortcode is located here:

/root dir of my site/content/pl/blog

This way I solved the problem. I think you can try. If you have any questions, do not hesitate to ask me, please.

@anvithks
Copy link
Owner

anvithks commented Mar 20, 2023

@corei8 @sysadmin-info You can take a look at how the shortcode is embedded and the Hugo site config in the demo site here

This site is built with the minimal theme and is deployed using Netlify.

@sysadmin-info
Copy link

@corei8 @sysadmin-info You can take a look at how the shortcode is embedded and the Hugo site config in the demo site here

This site is built with the minimal theme and is deployed using Netlify.

I figured it out. In the config.toml where the base url is defined instead of / it has to be https://example.com/ not https://example.com or / The / at the end of the address is crucial.

@sysadmin-info
Copy link

The initial installation did not work at all. But then I ran across this guide and I can get the shortcode to start loading the PDF, but it never actually loads it: the wheel just keeps on spinning.

I figured it out. In the config.toml where the base url is defined instead of / it has to be https://example.com/ not https://example.com or / The / at the end of the address is crucial.

@ai4bing
Copy link

ai4bing commented Nov 24, 2023

I also have this issue even when using

hugo server --baseURL "/"

@sysadmin-info
Copy link

I also have this issue even when using

hugo server --baseURL "/"

Read one more time carefully my answer.
I figured it out. In the config.toml where the base url is defined instead of / it has to be https://example.com/ not https://example.com or / The / at the end of the address is crucial.
So instead / use your base address with / at the end eg. https://sysadmin.info.pl/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants