Transitioning to the new template system - Static Pages

I am transitioning to the new template system (>= v0.146.0). Everything seems fine except for the static pages, which used to work but are now broken.

My old folder structure (pre-v0.146.0)

/content/contact.md

/layouts/page/contact.html

where in contact.md I explicitly specify which custom layout to choose, e.g.,

---

title: “Contact Us”
Description: “You can reach us out here”
layout: “contact”

---

How do I get this working with the new template system?

Many thanks :herb:

(v 154.2)

  • without a layout /content/contact.md

    +++
    title = 'Contact'
    +++
    

    layout in layouts/contact/page.html

  • use custom layout in /content/contact.md

    +++
    title = 'Contact'
    layout = "contact"
    +++
    

    layout in either of (ordered by priority)

    1. layouts/contact.page.html
    2. layouts/page.contact.html
    3. layouts/contact.html
    4. layouts/contact/page.html

the /page/ ist just a path component in 146+

1 Like

Hmm… @irkode, I just tried with and without layout as you suggested but none of them worked for me. I am just getting a blank page instead. Is it possible that something prevents rendering of the static pages?

maybe. but its hard to tell without the exact sources.

what I can tell: these settings are tested woth a quite bare setup before posted.

best you share your repo.

That construct is no longer supported.

@musthero do this instead.

Delete the public folder and try again.

1 Like

Oh, I think I was able to nail down what causes this behavior!

My content folder has a soft-link, called articles, which leads to a separate git repo with *.md files. With Hugo version v0.115.3, this set-up worked fine. But with Hugo v0.154.2, soft-links are not allowed anymore (I believe due to security reasons), and I had to replace my soft-links in content by modules in the Hugo config. Thus, the updated config.toml looks like this,

[module]   
   [[module.mounts]]     
     source = ‘../myarticles-data/articles’     
     target = ‘content/articles’

With Hugo v0.154.2, the new set-up works for the article posts from the source folder, yet it breaks generation of static pages from content (e.g., /content/about.md, /content/contact.md). As you can see, target parameter contains word ‘content‘ and this, I believe, prevents static pages from being produced.

If ‘content‘ is replaced, say, by ‘static‘, namely

target = ‘static/articles’

then static pages are being indeed generated. But, this obviously prevents then the article pages being produced.

As I said, my old set-up worked before because soft-links in the content were allowed. Now, I believe I just need to figure a better way of incorporating articles, a standalone git repo with .md files, into content folder. Could you please give me some hints about what’ is the recommended way of doing that now?

@razor , thank for the suggestion to remove ‘public‘ directory. It helped me immensely to debug the code. Before that, I was just getting blank screen in the browser somehow.

it always confuses me while reading. A page in content is not static in the sense of Hugo. so I would not call it like that. It’s a content file in the root section

softlinks

have been deprecated in v0.123.0 :wink: nothing to do with 146+

mounts

remount your project root content folder

[module]
   [[module.mounts]]
     source = "../myarticles-data/articles"
     target = "content/articles"
   [[module.mounts]]
     source = "content"
     target = "content"

from the mount docs

In either case, if you still need one of the default mounts, you must explicitly add it along with the new mount. Because custom mounts override defaults, any necessary default mappings must be re-added manually after you introduce your custom configuration.

you may also fine grain the mounts using include stuff using glob patterns (see link above)


p.s no need to quote each line separately for code here.

```toml
[module]
   [[module.mounts]]
     source = "../myarticles-data/articles"
     target = "content/articles"
```
1 Like

@irkode , remounting the content folder indeed solved my problem! Thank you very much :+1:

Here are just some comments for completeness.

Yes. I am transitioning from v0.115.3. So it is not surprising.

I agree, I’m not comfortable with my notation either. I just didn’t know a better way to describe which files I had in mind.

I’ve fixed this now. I didn’t quote individual lines — it happened automatically in the web editor. I’ll keep an eye on it in the future. Thank you!

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