# Access file system path of content directory when module.mounts is used

**URL:** <https://discourse.gohugo.io/t/access-file-system-path-of-content-directory-when-module-mounts-is-used/33228>\
**Category:** support\
**Created:** [June 4, 2021, 12:09pm UTC](https://discourse.gohugo.io/t/access-file-system-path-of-content-directory-when-module-mounts-is-used/33228 "2021-06-04T12:09:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vvasuki](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/vvasuki/32/10158_2.png) [@vvasuki](https://discourse.gohugo.io/u/vvasuki)\
**Post date:** [June 4, 2021, 12:09pm UTC](https://discourse.gohugo.io/t/access-file-system-path-of-content-directory-when-module-mounts-is-used/33228/1 "2021-06-04T12:09:19Z")

</div>

Ordinarily, as in [this shortcode](https://github.com/sanskrit-coders/sanskrit-documentation-theme-hugo/blob/9b7e01a785a4cb16042c4a424926bf933e6b40cd/layouts/shortcodes/gallery.html#L13), the below works fine for computing a certain path:

`{{- $rootDir := $.Get "rootDir" | default (print "/content/" .Page.File.Dir) }}`

However, on a windows machine (Hugo Static Site Generator v0.72.0/extended windows/amd64 BuildDate: unknown), we have the following config for which the above fails on use with readDir (`error calling readDir: failed to read directory "/content/sAma\\meta\\paravastu-sampradAyaH\\images\\."`):

```auto
  [[module.mounts]]
    source = "../vedAH-content"
    target = "content"

```

How would I avoid hardcoding `/content/`? I tried looking at [Site Variables | Hugo](https://gohugo.io/variables/site/) and did not notice any variable which will give me the path to the content directory. I want to avoid doing something ugly like passing it in .Site.Params. Any ideas?

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [June 4, 2021, 1:28pm UTC](https://discourse.gohugo.io/t/access-file-system-path-of-content-directory-when-module-mounts-is-used/33228/2 "2021-06-04T13:28:36Z")

</div>

> [@vvasuki](#):
>
> Any ideas?

Yes.

Change your shortcode to access images as page or global resources.

[https://gohugo.io/content-management/page-resources](https://gohugo.io/content-management/page-resources)  
[https://gohugo.io/content-management/image-processing](https://gohugo.io/content-management/image-processing)

---

<div class="post-metadata">

**Author:** ![vvasuki](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/vvasuki/32/10158_2.png) [@vvasuki](https://discourse.gohugo.io/u/vvasuki)\
**Post date:** [June 4, 2021, 3:02pm UTC](https://discourse.gohugo.io/t/access-file-system-path-of-content-directory-when-module-mounts-is-used/33228/3 "2021-06-04T15:02:52Z")

</div>

Page resources wouldn’t work if I want the shortcode to list contents of an arbitrary content directory (passed as argument to the shortcode). What are global resources (googling did not help)? Would it overcome this problem?

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [June 4, 2021, 3:06pm UTC](https://discourse.gohugo.io/t/access-file-system-path-of-content-directory-when-module-mounts-is-used/33228/4 "2021-06-04T15:06:44Z")

</div>

> [@vvasuki](#):
>
> Page resources wouldn’t work if I want the shortcode to list contents of an arbitrary content directory

Yes, it would. See:  
[https://gohugo.io/functions/getpage](https://gohugo.io/functions/getpage)

> [@vvasuki](#):
>
> What are global resources

Anything in the `assets` directory. See:  
[https://gohugo.io/content-management/image-processing/#the-image-resource](https://gohugo.io/content-management/image-processing/#the-image-resource)

---

<div class="post-metadata">

**Author:** ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)\
**Post date:** [June 6, 2021, 3:07pm UTC](https://discourse.gohugo.io/t/access-file-system-path-of-content-directory-when-module-mounts-is-used/33228/5 "2021-06-06T15:07:29Z")

</div>

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