How to use Bootstrap in SSG website
Answered
Donskoy posted this in #help-forum
DonskoyOP
I have blog listing website where I build using Next js SSG. I did installed the bootstrap and used it. it is working fine when i runs it locally. but when I create build using
example: abc/blog is working fine but abc/blog/1212 is not working as expected.
output: "export" for SSG website. but when I try to open the html pages of out/dist directory. the bootstrap breaks and site is not showing as it should be.example: abc/blog is working fine but abc/blog/1212 is not working as expected.
36 Replies
DonskoyOP
here is the structure.
I have my import of bootstrao in app > layout.js
I have my import of bootstrao in app > layout.js
@Donskoy here is the structure.
I have my import of bootstrao in app > layout.js
which bootstrap are u using?
there are two versions
DonskoyOP
Here are the screenshots
oh
u dont need to do that
check this
DonskoyOP
do you mean i should use Script?
yup
DonskoyOP
okay, and also will it work in SSG?
yes
since its a bundle u can directly offload your bootstrap script to a cdn
nextjs will load that for u
before page gets rendered
but u have options to customize the behaviour
DonskoyOP
The issue is this, When I directly hit this page. it broke
@Donskoy The issue is this, When I directly hit this page. it broke
are u using the Script component?
DonskoyOP
oh that will not work for local scripts
DonskoyOP
let me check
is this correct ?
looks g ood
DonskoyOP
still same
check in browser console
if the script gets loaded
DonskoyOP
uhm that doesnt look healthy
u might need to take care of the other errors first
DonskoyOP
these only comes when i directly hit From URL
DonskoyOP
assetPrefix: "./",
issue is due to this
issue is due to this
due to the assetPrefix the issue is coming, in next.config.js
DonskoyOP
I have added assetsPrefix path as my domain name and it worked.
Answer