Generate Static Site

Hi,

When generating public folder with hugo, I have some questions which I’m not sure of.

  1. Would it be possible to only keep html files for all contents? So that there will be no markdown files in it.
  2. Can the same file structure be maintained while generating public dir? So that all posts are under public/contents/posts/ instead of public/.
  1. This is how Hugo works out of the box.
  2. Remove the “content” part and it is how Hugo works out of the box. “/content/post/2023/a-very-nice-post.md” → “/public/post/2023/a-very-nice.post.html”. This behaviour can be changed in many ways with settings.
2 Likes

Thanks Fredrik. Could you please share how to configure the setting to maintain the file structure?
e.g. The file structure is

- MyHugoSite
  - content
    - Posts
      - A
        - a.md
      - B
        - b.md
      ...
    - Archive
      - AA
        -aa.md
      ...
  - assets
  - static
  - layouts
  ...

When generating public dir, the file structure becomes


- public
  - A
    - a.html
  - B
    - b.html
  ...
  - AA
    -aa.html
  ...

Is there a way to keep the structure as previously? Something like:

- public
  - content
    - Posts
      - A
        - a.html
      - B
        - b.html
      ...
    - Archive
      - AA
        -aa.html
      ...
  - assets
  - static
  - layouts
  ...

You are more likely to receive a prompt and accurate response if you post a link to the public repository for your project.

See Requesting Help.

Let us see your code

Include a link to the source code repository of your project, because we really need the context of seeing your templates and partials to be able to help you. It is trivial to do a quick git clone on your repo, then run hugo server in your project, to help you out. On the other hand, recreating your code from screenshots, or sort of guessing at it, is not.

If you can’t share your repository for whatever reason, consider creating a dummy repo that you can share, which reproduces the problem you’re experiencing.

I see. A simple repo was just created: Ros Ark / MySite · GitLab

In your site configuration you have:

[Permalinks]
  # posts = ":year/:month/:filename"
  posts = ":filename"

Which causes all of the posts to be published to the root of your public directory.

1 Like

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