Asset Loading Issue in Azure Static Web Apps with MkDocs-Material Sites in Subdirectories #1603
Unanswered
pushbroomsweep
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm hosting a static site on Azure Static Web Apps, built using MkDocs-Material. The site contains a main landing page and multiple sub-sites (each built individually using mkdocs) located in subdirectories (e.g.,
/sub-site1/
,/sub-site2/
). Each sub-site has its ownindex.html
, assets (CSS, JS, images), and content pages.Here's the structure of the deployed site:
Problem
While the main landing page loads correctly, sub-site pages fail to load their CSS and JavaScript and the navigation doesn't work properly in the sub-sites either. The browser tries to load the assets from the subdirectory of the current page (e.g.,
/sub-site1/page1/assets/stylesheets/main.css
) instead of the correct directory root for the sub-site (e.g.,/sub-site1/assets/stylesheets/main.css
).Debugging Insights
site_url
inmkdocs.yml
is set to the correct sub-site URL (e.g.,https://example.com/sub-site1/
) and for the landing page, it is set tohttps://example.com/
.use_directory_urls: true
is used in all builds (I have tried setting this to false as well).staticwebapp.config.json
looks like:NS_ERROR_CORRUPTED_CONTENT
or 404s for asset files.https://example.com/sub-site1/page1
by clicking on a link in the sub-site home page (which loads without any styles or scripts), it shows ashttps://example.com/page1
.Question
How can I configure MkDocs and Azure Static Web Apps so that sub-site pages correctly load their assets (CSS, JS) without attempting to fetch them relative to the current page? Is there a specific MkDocs or Azure Static Web Apps configuration I might be missing? Any insights or similar experiences would be greatly appreciated! Or if it is even possible to host a structure like this (where we have a top level site as well as sub-sites built separately as sub-folders which will be linked as paths to the domain) as a static web app?
Beta Was this translation helpful? Give feedback.
All reactions