Change output folder path in public folder

Hi,

I am new to Hugo and using gohugotheme.

When i build with Hugo command my public folder is getting created and it has output folder which consists of CSS and JS folders(public/output/css).

I want to change it to something (public/public/output/css) folder structure.

Try setting publishDir to public/public in your config file

1 Like

This setting will change all the folders to public/public/. But i am trying to change only output/css to public/[somefolder]/output/css.

Only output folder path should be changed.

We’ll need to see how you’re currently constructing your CSS path, and where those CSS files live, in order to help you further

I have uploaded my Hugo here.

https://drive.google.com/open?id=1WYtK2Knz-jJiMSUkwqO0kOATQQ4Jpi5d

When i make hugo build my output folder is created at public/output.

what i am expecting the output is public/public/output.

Actual Problem

Reason why i need this output folder inside public is.

Initially when i make hugo build my public folder is created and the directory structure is

Public
api-reference
categories
css
dist
documentation
fonts
getting-started
images
img
output
share
and many single files

This is working in my hugo server.

I am using XAMPP server to deploy.

When i deploy public folder inside \xampp\htdocs .css and .js are not getting loaded. getting 404 exception.

The reason i have found is path is not correct for .css and .js files.

Copied my output folder inside public directory to \xampp\htdocs and .css and .js files were loaded properly and everything is working as expected.

I would like to change the path of output folder so that .css and .js files will be loaded.

If you have assets you want to be in a specific place under your site, just put them in /static where you want them. Hugo will simply copy the content of that to /public. So if you have /static/path/to/my/main.css it will be copied to /public/path/to/my/main.css. Then copy /public/* to /path/to/my/htdocs/ or wherever you’re serving from.

1 Like

it is looking for css file at this location

href="/output/css/app.min.7b23725c013f7650fd9e3f14b7f6b0bc02f71e14088ecd41bbe57661163fbcbb.css"

@zwbetz have you got any chance to look at my code ?

I’m still not following what is happening. To clarify, you’re doing the following, right? Also, I am not familiar with xampp server.

  1. Your site runs and displays fine with hugo server
  2. Build site with hugo
  3. Copy the contents of public dir to \xampp\htdocs
  4. CSS and JS files do not load

Yes correct. Xampp server internally uses Apache server.

Okay. So explain more what you did to “make it work”, and that may give us a hint on a solution

I have tried different ways to change the path of CSS file from
href="**/output/css/app.min.**7b23725c013f7650fd9e3f14b7f6b0bc02f71e14088ecd41bbe57661163fbcbb.css"

to

href="/public/output/css/app.min.7b23725c013f7650fd9e3f14b7f6b0bc02f71e14088ecd41bbe57661163fbcbb.css"

i am not sure how to do this.

Hmm. Perhaps someone else may help you. The issue is still not clear to me.

P.S. I’m suspicious of you having to edit deployed files. You shouldn’t have to do this.

What template code are you using to generate those strings in your <head>?

i have no idea about generate those strings in your <head> ?

where can i find that information in my source code.

I have placed my source code at
https://drive.google.com/open?id=1WYtK2Knz-jJiMSUkwqO0kOATQQ4Jpi5d

In your theme, check layouts/_defaults/baseof.html.