Comments (4)
This is a Github Pages thing, everything works fine locally.
I recreated the app in NextJS and had the same problem with defining a base URL for Github Pages. I tried out deployment on Vercel and everything works fine. I guess the moral is that Github Pages is 💩.
The thing is that I came from a Hugo background and that allows to create shortcode markdown pre-processors. So markdown image link would look like this ![MyTV]({{< picturepath >}}DSC_1625.jpg)
that would point to {{ .Page.Site.Params.picturepath }}.
that got its value from a constant config file. Links were relative to baseURL variable (with the value being either https://oskar-anderson.github.io/RepoName/
or localhost
) defined in the config file. This system works well with Github Pages.
The solution seems to run all markdown content through a templating engine that replaces {{ BASE_PATH }} with a value from appsettings.json before it gets served as a Razor Page. Also all links would have to use this BASE_PATH constant.
I realize now that my problem has nothing to do with this library. Sorry for wasting time.
from aspnetstatic.
The output destination folder has no bearing on the content of generated pages. It just specifies the base folder for where the files for the static pages are to be placed.
The issue is with the ~ based relative paths; they don't work properly. Use "/my-page" instead of "~/my-page". This is not something that's unique to AspNetStatic, btw. Just use the AspNet tag helpers (asp-* or UrlHelper.*) to generate the URL to your pages, and your links will work properly regardless of the site's base URL/domain.
from aspnetstatic.
I understand that the output directory must be wwwroot
, since this would be the only way to develop the app in dotnet watch
mode and then generate static pages that still work with all the static css, js files placed in wwwroot/static
. Then everything other than static
in wwwroot
could be gitignored.
I tried using asp-pages
tag, but it does not work. I created a demo of my workflow of what I am trying to achieve here.
I would appreciate if you could have a look. Some instructions on running:
- a) Clone the project or b) if the permission allow use my repo (I sent a collaborator invitation).
1.a.1. EnableSettings -> Actions -> General -> Workflow permissions -> Read and Write permissions
1.a.2. Select gh-pages branch and root directory inSettings -> Pages -> Build and deployment
1.a.3. Hopefully every push to master should now generate the pages and place content fromwwwroot
into gh-pages branch. - You can hard reset to 4ceffab5 since changes after that did not do anything
Running the project is done by dotnet run --project WebApp
or dotnet run --project WebApp -- stop
to only generate static pages. Generated files can be viewed by python pyServer.py
in wwwroot
directory. But most of the time if it works with dotnet run
I would just push it to Github Pages and expect it to work.
from aspnetstatic.
Hi @oskar-anderson,
I cloned your AspNetStaticDemo repo, then setup an IIS website pointing to the wwwroot folder. I also took the content of wwwroot (sans pyServer.py) and copied them to another unrelated folder (c:\oskar), and set the IIS site to point to it. In both cases, it all works fine; all img/css/js content loads/displays as expected and all inter-page links work as expected. I don't see a problem here; at least not one that's related to AspNetStatic.
Also, the asp-page tag helper in your Header.cshtml code...
<a class="nav-link" asp-page="Contact">Contact</a>
...doesn't work b/c there's no Contact.cshtml page in your project!
from aspnetstatic.
Related Issues (8)
- Any support for Blazor web project HOT 1
- Support for embedded url rewrite and hook for custom slug generation HOT 5
- Typo in GenerateStaticPages() method HOT 4
- Invalidation service HOT 2
- Multiple question about Features HOT 2
- [Feature Request] Can we do something when processing resource? HOT 3
- Common StaticResourcesInfoProviders HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aspnetstatic.