Is this possible?

Hi,

Following is my directory

.
├── assets
│ ├── icons
│ │ └── logo.svg
│ └── scss
│ └── _variables_project.scss
├── config.toml
├── content
│ └── en
│ ├── blog
│ ├── community
│ ├── docs
│ ├── featured-background.jpg
│ ├── _index.html
│ ├── logo.png
│ ├── search.md
│ └── start.png
├── layouts
│ ├── partials
│ │ ├── community-links.html
│ │ └── hooks
├── package.json
├── package-lock.json
├── README.md
├── resources
│ └── _gen
│ ├── assets
│ └── images
├── static
│ ├── css
│ │ └── tabs.css
│ └── js
│ └── tabs.js
└── themes
└── docsy
├── assets
├── config.toml
├── …

The directory is under /home/hugo/ and the config.toml has the following config

contentDir = “content/en”

from inside the /home/hugo directory ran hugo as follow

hugo serve --bind=192.168.1.5 --baseURL=http://192.168.1.5 -p 8080 --disableFastRender --navigateToChanged --ignoreCache --buildFuture

it all works fine but is it possible to link (via HREF) to a file that is outside /home/hugo ? in my case there is a file called README.md that
reside under /home/friendsite

Thanks

Yes,

See:

You can have as many content dirs as you want, and as long as the mount is defined in the main project, it can point anywhere on the file system, e.g. “/home/foo/bar”.

Thanks.

So I have currently configured the config.toml as follow

[module]
[[module.mounts]]
source = “…/…/friendsite”
target = “static”

Tried accessing the file using the url http://192.168.1.5:8080/static it doesn’t work ?

The target root (static, content, data etc.) matches the “virtual folder” in Hugo, so to speak.

So if you have:

[module]
[[module.mounts]]
source = “…/…/friendsite”
target = “static”

And there is a file named “…/…/friendsite/logo.png” you should be able do do http://localhost:1313/logo.png and similar

Thanks @bep it works. I have another question

If I have

[module]
[[module.mounts]]
source = “…/…/friendsite”
target = “static”

source = “…/…/differentfriendsite”
target = “static”

and both inside the friendsite and differentfriendsite has the same filename README.md how to differentiate them in the config ?

You need to mount them into different subdirectories, e.g:

[module]
[[module.mounts]]
source = “…/…/friendsite”
target = “static/friend1”
[[module.mounts]]
source = “…/…/differentfriendsite”
target = “static/friend2”

Thank you very much @bep

It works like a charm :slight_smile:

1 Like

@bep The file inside …/…/friendsite called README.md has markdown like follows

---
title: "GVisor"
date: 2019-07-31
weight: 4
description: >
  Using addons
---
## gVisor Addon

but it came out as raw text (displayed as it is). Tried changing it to content/friend1 but still not showing ?

Thanks

Found the following sample https://github.com/bep/my-modular-site/blob/master/config.toml , tried some of the following combination to see if it works

 [[module.imports.mount]]
  path="../themes"
 [[module.imports.mount]]
  path="../themes/docsy"
[[module.imports.mount]]
    path="docsy"
 [[module.imports.mount]]
  path="../static"
 [[module.imports.mount]]
 path="../layouts/shortcodes"
 [[module.imports.mount]]
  path="../layouts/partials"

Mount it in content if you want it processed as markdown

To understand the full powers of mounts in Hugo (which I think is a pretty unique thing for Hugo, esp. considering the recursiveness and that you can mount folders on GitHub etc.), I think it’s important to read the documentation and esp. understand the relationship between the mount target and the different component types in Hugo (static, content etc.)