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

Relative paths for relocatable websites #946

Closed
staticfloat opened this issue Mar 2, 2022 · 4 comments
Closed

Relative paths for relocatable websites #946

staticfloat opened this issue Mar 2, 2022 · 4 comments

Comments

@staticfloat
Copy link

I would like to create multiple franklin-hosted (well, really PkgPage-generated) websites on the same domain! I see that all of the resources are referred to by absolute path, and the prepath argument always has a / prepended to it. Is there some way that we can provide prepath=nothing or similar to signal to Franklin that we want a relocatable HTML generated, and thus it should not have the / prepended to the prepath? That way the links to resources can be relative and not absolute.

Thank you!

@tlienart
Copy link
Owner

tlienart commented Mar 2, 2022

(sorry if I misunderstood your message)

If you have a base URL example.com you want to use and have projects at

  • repo1 -> example.com/project1/index.html and related pages and assets with example.com/project1/
  • repo2 -> example.com/project2/index.html and related pages and assets with example.com/project2/
  • etc

you can achieve this by having prepath="project1", prepath="project2" etc.

Let's say that in repo1 you have an image at _assets/image1.png and that you want it on the landing page, you can use a relative path like so in the markdown:

<!-- index.md in repo1 -->
![image 1](/assets/image1.png)

this will be mapped to example.com/project1/assets/image1.png. Does this not work for you?

If not, would you mind either adding me to a repo or showing me the produced HTML and what you'd like instead? (I understand that you'd like relocatable paths but this is not trivial to do with the current design and I'm not yet convinced this is required by what you're trying to do)

@zsoerenm
Copy link

zsoerenm commented Mar 2, 2022

I think the problem is that the prepath might not be available beforehand or might change with every commit.
For example, let's say you'd like to build a PkgPage website with every commit as an artifact. This might be accessible like the following:

  • /commid-id1/report/
  • /commit-id2/report/

etc.
With relative paths this would be much easier to handle.

@tlienart
Copy link
Owner

tlienart commented Mar 2, 2022

Assuming you use GA to generate your websites, you can modify this https://github.com/tlienart/PkgPage.jl/blob/8716a293097213b63c078680e7d74f35d28df353/.github/workflows/DeployPage.yml#L17-L22

into

- run: julia -e '
            import Pkg; Pkg.activate("page/Project.toml"); Pkg.instantiate();
            using NodeJS;
            run(`$(npm_cmd()) install highlight.js purgecss`);
            import PkgPage;
            PkgPage.optimize(input="page", output="", prepath="commit-" * "${{ env.GITHUB_SHA }}"[1:7])'

i.e. you can pass that prepath thing at deployment time.


PS: I'm not trying to be difficult, you're not the first ones stumbling upon the relative path thing, I understand that in your view it would just be easier to get relative paths but to make it clearer, this is not something I can easily do now with Franklin, it'll take far less time to try to see if something like the above would do the trick for you.

@tlienart
Copy link
Owner

I'll close this but feel free to reopen if I can help out more

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

3 participants