Any way to use variable in `content/` that is initialized inside `layout/`?

I wrote this code inside layouts/_default/single.html and it produces this nice little upload link inside $uloadurl

{{ $File := .File }}
{{ $Site := .Site }}
{{ $fileDir := replace $File.Dir "\\" "/"}}
{{ $uploadurl := $File.LogicalName | printf "%s%s" $fileDir | printf "%s%s" $Site.Params.uploadURL }}

However, using $uploadurl obviously does not work in content/

I’ve tried:

  • Using layouts/shortcodes/ghupload.html and written the code above, over there. It seems the{{ .File }} context is lost there :sweat_smile:
  • So then I tried layouts/partials. A different problem but using layouts/_default/single.html seemed good enough. I can generate and make upload links inside it. But I wish I could send/use the value of variable instead(enabling me to do things inline).

I am thinking of:

  • getting value of .File from a hidden span :sweat_smile: and delivering it to the required destination such as
    {{ $File := "the/file/path" }}
    {{ ghupload $File }}

idk atm. Am I overthinking this? Is this stupidity?

I just want to:

  • display upload link for each github page.
  • I’m making a folder to upload files and it should point to it. Something like this