Git Product home page Git Product logo

Comments (9)

tcwilkinson avatar tcwilkinson commented on June 23, 2024

As a temporary workaround, I inserted the following into gallery.html

{{ $siteURL := .Site.BaseURL }}

[snip]

   {{- $linkURL := print $siteURL "/" ($.Get "dir") "/" .Name | absURL }}<!-- absolute URL to hi-res image -->
   {{- $thumbURL := print $siteURL "/" ($.Get "dir") "/" $thumb | absURL }}<!-- absolute URL to thumbnail image -->

It works, although not sure if it isn't a little "hacky"...

from hugo-easy-gallery.

liwenyip avatar liwenyip commented on June 23, 2024

Thanks @tcwilkinson, this is an oversight on my part.

Probably more efficient to do something like

{{ $imgBaseURL := print .Site.BaseURL "/" ($.Get "dir") "/" }}

[snip]

   {{- $linkURL := print $imgBaseURL .Name | absURL }}<!-- absolute URL to hi-res image -->
   {{- $thumbURL := print $imgBaseURL "/" ($.Get "dir") "/" $thumb | absURL }}<!-- absolute URL to thumbnail image -->

I'm not in front of the correct computer for me to test this, so feel free to get something working and then submit a PR.

from hugo-easy-gallery.

jbrice avatar jbrice commented on June 23, 2024

@liwenyip Tried your patch for this problem as I have a documentation site that runs in a sub-folder of server root. it looks as if the patch works for the background URLs in "gallery from folder" mode, but does not fix "gallery from list" which suffers from the same problem.

Unfortunately I don't have time just now to triage this properly, but I'm sure you know your code well enough to spot why this is happening.

from hugo-easy-gallery.

liwenyip avatar liwenyip commented on June 23, 2024

Thanks @jbrice

I'm also kinda busy at the moment; so I'll add it to my to-do list. But I'd be very happy for someone else to fix and submit a PR in the meantime.

from hugo-easy-gallery.

jbrice avatar jbrice commented on June 23, 2024

Happy to put some time to it, and have had a go but "retired hurt" as I am a newcomer to Hugo/golang template coding and finding your code somewhat cryptic, probably as a result of that.

I have been unable to find much in-depth documentation or "power user" examples of Hugo template coding. Are there any resources you would recommend?

from hugo-easy-gallery.

liwenyip avatar liwenyip commented on June 23, 2024

@jbrice the Hugo documentation covers basics, and is improving all the time.

For more complicated questions, post/search in https://discourse.gohugo.io/

Good luck!

from hugo-easy-gallery.

jbrice avatar jbrice commented on June 23, 2024

Thank you!

Am making progress. However from a newcomers point of view a lot of the documentation looks great, but in practice feels as if it has been written by people who are much too familiar with the topic they are writing about. And https://discourse.gohugo.io/ is full of great nuggets but needs a lot of excavation to get to many of them.

from hugo-easy-gallery.

liwenyip avatar liwenyip commented on June 23, 2024

from hugo-easy-gallery.

jbrice avatar jbrice commented on June 23, 2024

@liwenyip
The mists are clearing and I think that the fix is fairly simple. I have found that the best (only?) way to use the current version of Hugo (V0.25.1) in a sub-folder of the server is to create the site with baseURL set to the full path (domain plus path) to the site's root folder plus canonifyURLs = true. Hugo then automatically prepends all asset URLs beginning with "/" with the baseURL string, thus essentially doing the job of the additional code you suggested a short while ago (but on a site-wide basis).

However this URL completion is not foolproof and does not seem to process urls in CSS backgrounds in this way, including the one on line 13 of the current version of figure.html. So I have proposed a simple change that I have found to work OK on a non-server-root test site, when used along with an appropriate baseURL and canonifyURLs = true set in the config.

from hugo-easy-gallery.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.