Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML files in subfolders do not get styles / scripts. #46

Open
Andrew1431 opened this issue Apr 9, 2020 · 4 comments
Open

HTML files in subfolders do not get styles / scripts. #46

Andrew1431 opened this issue Apr 9, 2020 · 4 comments

Comments

@Andrew1431
Copy link

Describe the bug
In your documentation, it clearly states:

You may add as many html pages as you’d like to the root level directory, they will automatically be copied and minified into the dist/ folder upon building your site.

So I don't know if this a bug report or a feature request:

I want users to be able to visit website.com/survey instead of survey.html so I've put a survey/index.html file there. It works technically, I see the HTML, but it is not receiving any of the styles or javascript code injection.

To Reproduce
Steps to reproduce the behavior:

  1. Create a subfolder for HTML (Very standard operation I assume?)
  2. HTML inside there will load but it will not get the webpack injections or live reload.

Expected behavior
I expect to be able to nest my HTML for cleaner URLs

Desktop (please complete the following information):
Platform Agnostic

@CharnjeetIotasol
Copy link

Have you found any way to load style and script on subfolder.

@kesavanv
Copy link

kesavanv commented May 23, 2020

You will be able to organize HTML files in folders, by adding the below code

filename = dir.substring(6);
in https://github.com/ericalli/static-site-boilerplate/blob/master/config/webpack.plugins.js#L60

Can be done better, if we alter the actual code.

@redordev
Copy link

Would be great if we could have different directories and root level pages e.g.

contact.html
index.html
insights.html
service.html
team.html
blog/story1.html
blog/story2.html
insights/insight1.html
insights/insight2.html
services/service1.html
services/service2.html
team/member1.html
team/member2.html

Any idea how to change the script to do this?

@BenceSzalai
Copy link

BenceSzalai commented Mar 4, 2021

All you need to do is modify webpack.plugins.js to instead of using path.basename(dir) which throws away the directory path, extract the html "filename" from dir including the relative path compared to src. Something like:

const filename = path.relative(config.paths.src, dir);

Actually this could be updated in the repo, as it would be more versatile.

Together with changing line 58 as:

const generateHTMLPlugins = () => glob.sync(`./${config.paths.src}/**/*.html`).map((dir) => {

which would allow the src path to be properly modified here, but that is not directly related to this issue, just saying, as once config.paths.src is being used to generate the relative filenames it'd be preferable to use that to gather the files as well instead of hardcoded src as of now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants