Jieiku / abridge

Fast & Lightweight Zola Theme
https://abridge.pages.dev/
MIT License
161 stars 44 forks source link

Which release is the most compatible for Cloudflare deployments? #190

Closed IPlayZed closed 1 month ago

IPlayZed commented 1 month ago

Hi!

I am using this theme on my site and I really like it. I am doing Cloudflare deployments, but it uses Zola version 0.17.2. Which release or commit do you think is the best suited for that version?

Thank you for the help! πŸ˜„

Hysterelius commented 1 month ago

I personally use Github CI to build my website before deploying it Cloudflare Pages, which I assume what you mean. This means I can choose which version of Zola I run.

For abridge, I would recommend the last major version it should work with Zola and be up to date.

This is my own Github action which builds the site and deploys it:

# .github/workflow/main.yml
on: 
  push:
    branches:
      - main
name: Build Zola website
jobs:
  build-bundle-deploy:
    runs-on: ubuntu-latest
    steps:
      # Check-out repository under $GITHUB_WORKSPACE
      - name: Checkout πŸ“‹
        uses: actions/checkout@v3
        with:
          submodules: true
      # Build static pages w/ Zola
      - name: Build πŸ—οΈ
        uses: shalzz/zola-deploy-action@v0.19.1
        env:
          BUILD_ONLY: true
        # Deploy to Cloudflare Pages
      - name: Deploy πŸš€
        uses: cloudflare/pages-action@v1
        with:
          apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
          accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
          projectName: ${{ secrets.PROJECT_NAME }}
          directory: public

Just pop this file in .github/workflows/main.yml and add your secrets into the repository and you should be all good ☺️

IPlayZed commented 1 month ago

@Hysterelius

I personally use Github CI to build my website before deploying it Cloudflare Pages, which I assume what you mean. This means I can choose which version of Zola I run.

No, that is not my case. I am using Cloudflare's guide and the site is built using their infrastructure. This is completely independent of GitHub Pages.

What I am trying to achieve here is using a fixed version of Zola and Abridge which I know will work, regardless of what is the latest supported version. That is why I would like to either include a specific release commit from this project or simply download a release and drop it in.

Also, when I tried setting the shlazz/zola-deploy-action hook, it gave me this failure. I am not sure what is causing this based on the logs. I would guess that I am not allowed to add an external media source as an URL? I am really not sure what is happening, but I removed that GH action anyway and this is a separate issue for that project probably.

Jieiku commented 1 month ago

The abridge demo is built using cloudflare's guide. This was previously discussed here: https://github.com/Jieiku/abridge/issues/158

You have to either change the build system at cloudflare to version 1 or use the asdf plugin. For the abridge demo I am using the asdf plugin instead of changing the build system to version 1.

PS: Thanks Hysterelius for showing how to do it using a github action!

EDIT: the issue I posted was the initial attempt. so I am going to double check cloudflare now and outline it again, as I believe I am now using npm at cloudflare for the PWA.

Jieiku commented 1 month ago

Because the demo is also hosted on cloudflare pages you can use the latest commit. (so long as the demo is working you will know that it should also work for you)

If you are using Abridge as a submodule then it should not upgrade farther than that until you update the submodule.

Not long ago I extended Abridge to support arguments: https://github.com/Jieiku/abridge/commit/d7a834c523e517b1f11c432ccbc9f46e96bdc1c0 and Hysterelius fixed an issue with the implementation https://github.com/Jieiku/abridge/commit/b5f911cae8ffdba91aa9be1db8e3466abdb0f30c

I no longer use an environment variable at cloudflare, I just pass the base-url to the node script.

Here is my current build command:

asdf plugin add zola https://github.com/Jieiku/asdf-zola && asdf install zola 0.19.1 && asdf global zola 0.19.1 && npm run abridge -- "--base-url https://abridge.pages.dev"

Here is a screenshot of the cloudflare page:

cloudflare

IPlayZed commented 1 month ago

Thank you I will check this myself. So I suppose I will use the latest release and use version 19.1 for Zola.

As long as there is no need to I will stick to that given release and version because the site already has all the functionality I would need.

Btw why are use passing the page URL instead of putting in it the config.toml?

Jieiku commented 1 month ago

Doing it this way allowed me to have both demos online at the same time. (There may also have been another reason, but I cannot remember)

https://abridge.pages.dev/ https://abridge.netlify.app/

IPlayZed commented 1 month ago

@Jieiku I saw you have the build action enabled for other branches as well. How you you make sure that the URL given to that specific deployment is used to generate links when Zola runs? For instance let's say I want to explore my current dev build on the Cloudflare deployment and it has the link b60c2d70.iplayzed-github-io.pages.dev Now, I can load and access this page, but all links on the site will point to the domain nopointers.work, as it is set in the config file, or if using your methodologies, it is set in the build command. Is it possible to set this base domain name dynamically somehow? I know this is not strictly related to this repo, but I do not know anyone else who set up this infrastructure.

Jieiku commented 1 month ago

I think what you are asking for is if there is a way to use relative links instead of absolute links.

I believe I asked this once when I was trying to make a site that would work off of disk.

There is one way I do something like this in javascript, but that is only to facilitate loading files in js:

https://github.com/Jieiku/abridge/blob/4e1c5e0c6cb23870e48d89beb55ffcf70aeb1c97/static/js/tinysearch.js#L43-L49

Searching the Zola issue tracker I found these: https://github.com/getzola/zola/issues?q=is%3Aissue+relative+in%3Atitle+is%3Aopen

One of them lead me to this: https://mreggtart.com/posts/relative-path-in-zola/

I use either zola serve or a self hosted instance on my proxmox server, so the domain name is never random, I know exactly what it will be and I pass it to the build command.

I hope some of this is helpful, sorry I cannot be more help.

EDIT: by the way thanks for pointing out the other branches, I actually don't make use of that feature, I am guessing those were the default settings at cloudflare, going to turn off the other branches now!

IPlayZed commented 1 month ago

One way I can think of to solve this is to run a (bash or anything else) script in the build command, which either sets the base url in the config file or sets it in the build command like you do. Basically one should just determine the first few characters (I think during URL generation Cloudflare uses 7 to generate the deployment URL) of the current commit (where HEAD is in the Git repo) and use that. Of course I am not sure if it is allowed to change something like a cloned source file during build on Cloudflare or if I could reference that value with an environment variable used in the build command and do your approach. Anyway, I will try to open a discussion about this on Cloudflare forums, I would be surprised if I were the first one with this issue.

EDIT: Thanks for linking me that blogpost. That is very helpful actually, as I have to valid base URL names for my site (nopointers.work is the one I rent and the other one which is generated by Cloudflare).

IPlayZed commented 1 month ago

But returning to my original question, if I use Zola version 17.2, I would assume that I am good as long as I am using Abridge version 2.3.0 or lower (as you did not mentioned in the release that which version is needed of Zola and your next release mentioned 18.0, thus logically assuming this). Can you confirm this as well?

For closing the issue, I would say that it would be productive if for Abridge releases there was some kind of best suited Zola version marked, which is tested that it actually works.

Jieiku commented 1 month ago

yeah, zola's release cycle is slow enough that I could probably draft a new abridge release per zola version.

Abridge development has slowed down a bit now that most things are feature complete, however I do continually work to keep the google lighthouse and yellowlabtools score at 100%, there was a google lighthouse fix not that long ago actually.

Anytime I draft a release for Abridge in the past it has been for the current version of zola so you could likely compare the dates. For my own personal website I simply just use the latest commit on the master branch.

Zola 0.17.2 was released Mar 19, 2023 so I would say you are probably correct, about Abridge 2.3.0

Old abridge releases are really just for historical purposes, if your not using the latest commit on master branch then I would try to use the latest abridge release unless you simply don't have access to a version of zola that recent for some reason.

Going forward I will add the zola version a release is meant to cover, like I did for the last abridge release.

Jieiku commented 1 month ago

Oh yeah! also if you browse the repo at a given release tag you can check the theme.toml file to see what version of Zola it was meant for:

https://github.com/Jieiku/abridge/blob/2.3.0/theme.toml

In the case of Abridge 2.3.0 it was Zola 0.17.2

You can also do this for individual commits!

IPlayZed commented 1 month ago

I see, thank you for the answer. I will close the issue.