emacs-love / weblorg

Static Site Generator for Emacs
https://emacs.love/weblorg
GNU General Public License v3.0
278 stars 20 forks source link

Can't copy static files #23

Closed lccambiaghi closed 3 years ago

lccambiaghi commented 3 years ago

Hi, I can't manage to reproduce a minimum example following the getting started guide. In particular, I cannot get to copy the static css files to the output folder.

I tried both by having the 'static' folder in the root of the site as well as having that as a subfolder of the 'theme' folder. Where am I supposed to put the 'static' folder?

Thank you!

clarete commented 3 years ago

hi @lccambiaghi! Sorry about that, I believe there are two little bugs on that feature right now:

  1. documentation: the getting started example should include a call to the weblorg-copy-static function
  2. code: If you're trying to copy the static files of the theme shipped with weblorg, using the snippet bellow will fix it; however, if you're trying to copy the static assets of your own theme (within the root directory of your site), then it will take a little change to weblorg-copy-static for that to work. we've been tracking that shortcoming on the issue #20 and we're making steady progress to get better support for theming :)

Thank you for taking the time to open the issue!

clarete commented 3 years ago

Hi! It's me again! 😄 now with better news! I just pushed a big change to this static asset copying mechanism in the commit https://github.com/emacs-love/weblorg/commit/e2ae9b14f9ad736f52a7b4275076bc24a45926f8. Alongside with this change, there's a new documentation article that explains a bit more in depths how paths work: https://emacs.love/weblorg/doc/file-paths.html

So now, if you have static files within your website's <root>/theme/static directory or if you're inheriting from a theme, weblog-copy-static will work as expected!!

I'm going to close this ticket but please feel free to re-open it or to open a new one if you stumble upon anything else.

Thank you again for bringing this up! 🙇🏾

lccambiaghi commented 3 years ago

Amazing, thank you very much for your help, I can confirm the resolution on my side!! Thanks for your brilliant work

JensAc commented 3 years ago

Hi, first things first: Thanks for the amazing effort of writing this website generator.

I am not really sure whether I get the purpose of the weblorg-copy-static function right. I have a very basic setup and assume that the default theme css should be copied over to my website directory, right? However, this is not happening for me with

(require 'weblorg)
(require 'templatel)
(setq weblorg-default-url "SOME-DIR/website/")

;; route for rendering each post
(weblorg-route
 :name "posts"
 :input-pattern "posts/*.org"
 :template "post.html"
 :output "output/posts/{{ slug }}.html"
 :url "output/posts/{{ slug }}.html")

;; route for rendering the index page of the blog
(weblorg-route
 :name "blog"
 :input-pattern "posts/*.org"
 :input-aggregate #'weblorg-input-aggregate-all-desc
 :template "blog.html"
 :output "output/index.html"
 :url "output/")

 (weblorg-copy-static
  :output "output/static/{{ file }}"
  :url "output/static/{{ file }}")

Am I missing something?

semente commented 3 years ago

hey @JensAc

this is what I have:

(weblorg-copy-static
 :output ".build/assets/{{ file }}"
 :url "/assets/{{ file }}")

and it works if I have the assets in theme/static/ directory. I think it is mentioned somewhere that the files can live in static/ directory but it worked for me only in theme/static/.

JensAc commented 3 years ago

Thank you very much for the response @semente! If I understand you correctly, you have a theme/static directory in your website's root directory. However, I do not want to use any other theme than the default one and expect it to work out of the box, without copying any assets around. Am I right in that regard?

lccambiaghi commented 3 years ago

Hi @JensAc , just wanted to provide an example for you: https://github.com/lccambiaghi/lccambiaghi.github.io . Looking at publish.el and the project structure should help you, I hope!

clarete commented 3 years ago

@JensAc hi hi, thanks for asking the question. This isn't very well documented right now and changed sorta recently, which may have helped make it even more confusing. But right now there this is how it's working:

  1. if you're using the default theme and nothing else: you will need weblorg-copy-static because the default theme includes static assets
  2. if you are using the default theme but want to override either a static asset or a template: add stuff to your site/theme/templates and site/theme/assets. Files within these directories take precedence over the files in the theme;
  3. if you are using your own theme, has static assets and don't want to override the default: create your templates and assets within your theme (site/theme/templates and site/theme/assets) and disable the default theme completely by adding this before all your routes: (weblorg-site :theme nil).

I tried to capture some of this information in this article here, and any feedback on it would be appreciated: https://emacs.love/weblorg/doc/theming.html

clarete commented 3 years ago

Hi @JensAc , just wanted to provide an example for you: https://github.com/lccambiaghi/lccambiaghi.github.io . Looking at publish.el and the project structure should help you, I hope!

This is so cool! Thank you for sharing how you've been using the project @lccambiaghi! I'm so glad that it's been useful for you! @guilhermecomum suggested making a list of setups and put somewhere on the website, and yours look pretty sleek!! would that be OK? 😄

JensAc commented 3 years ago

@JensAc hi hi, thanks for asking the question. This isn't very well documented right now and changed sorta recently, which may have helped make it even more confusing. But right now there this is how it's working:

1. if you're using the default theme and nothing else: you will need `weblorg-copy-static` because the default theme includes static assets

2. if you are using the default theme but want to override either a static asset or a template: add stuff to your `site/theme/templates` and `site/theme/assets`.  Files within these directories take precedence over the files in the theme;

3. if you are using your own theme, has static assets and don't want to override the default: create your templates and assets within your theme (`site/theme/templates` and `site/theme/assets`) and disable the default theme completely by adding this before all your routes: `(weblorg-site :theme nil)`.

I tried to capture some of this information in this article here, and any feedback on it would be appreciated: https://emacs.love/weblorg/doc/theming.html

Alright, I see. That was actually also what I understood. However, for some reason I get no theming, when firing (weblorg-export). Maybe there is a configuration issue on my side. However, what I actually wanted to do is the following:

I am not very familiar with html and css. Therefore, I wanted to use the default theme as starting point. Thank you very much for providing the example, @lccambiaghi. I think I will be able to proceed somehow...

lccambiaghi commented 3 years ago

I moved my blog to weblorg, just finished setting up the domain. I also wrote a blog post talking about weblorg, here it is: https://luca.cambiaghi.me/posts/weblorg.html . Thanks again for your great work!

clarete commented 3 years ago

Alright, I see. That was actually also what I understood. However, for some reason I get no theming, when firing (weblorg-export). Maybe there is a configuration issue on my side.

Hi @JensAc!

Thank you for sharing more data, it took me a bit to see it but I think it might be related to this line:

(setq weblorg-default-url "SOME-DIR/website/")

That defaults to http://localhost:8000 and the static asset links are generated with absolute URLs, so if you switch to a URL that you can access, it might work.

If your intention with that setting was to configure the final output directory, it unfortunately takes configuring the :output parameter of every route. I didn't really add any global settings for that because it's too specific of a configuration to each route.

clarete commented 3 years ago

I moved my blog to weblorg, just finished setting up the domain. I also wrote a blog post talking about weblorg, here it is: https://luca.cambiaghi.me/posts/weblorg.html . Thanks again for your great work!

@lccambiaghi Thank you so much for the kind words there. weblorg is still quite young, I'm so happy that you were still able to take advantage of it to build some thing so cool! thank you for helping shaping weblorg so it continues to be useful 😄 🙇🏾