emacs-love / weblorg

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

Still can't get a simple example to work #63

Open sangwon-hyun opened 2 years ago

sangwon-hyun commented 2 years ago

Hi,

I'm someone who really, really likes the idea of weblorg and who doesn't really know that much Lisp.

I just can't get even a simple example to work. I have simplified my publish.el file as much as possible, so that it's just one main.org file (and perhaps one css file).

I have a simple request! There still isn't a super simple example that you could just run emacs --script publish.el on, and see a website to come out of it. I'm sure once I see something like this, I'll be able to figure out incrementally how to customize, but I haven't even gotten one example to work.

(For the sake of completeness, here is the publish.el I'm using.)

(add-to-list 'load-path "~/emacs")

;; Setup package management
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(package-initialize)
(unless (package-installed-p 'use-package)
  (package-refresh-contents)
  (package-install 'use-package))

;; Install and configure dependencies
(use-package templatel :ensure t)
(use-package htmlize
  :ensure t
  :config
  (setq org-html-htmlize-output-type 'css))

(require 'weblorg)

(weblorg-site
 :template-vars '(("site_author" . "Justin")
          ("site_name" . "Justin's website")
          ("project_description" . "Justin")))

;; Set theme
(weblorg-site
 :theme #'weblorg-theme-autodoc)

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

;; fire the engine and export all the files declared in the routes above
(weblorg-export)
dr-neptune commented 2 years ago

Hi @sangwon-hyun,

I was able to get a working example by doing the following:

  1. clone the repository
  2. under the examples directory in the repository, copy the simpleblog example into its own directory examples/simpleblog/
  3. run emacs --script publish.el in your new simpleblog directory. This will generate all the posts in the posts/ folder
  4. install the httpd-server emacs package
  5. customize the variable httpd-port to use port 8000
  6. M-x httpd-serve-directory and serve the folder output/

Now you should be able to browse the resulting web page at localhost:8000. From here you can edit the posts, themes, etc to your liking

mrunhap commented 2 years ago

I didn't see any themes, and link to about or post not work too.

danielnemenyi commented 10 months ago

@404cn There's what looks like a mistake in the documentation, which my pull request above suggests a resolution to. The documentation states that the :output of weblorg-copy-static should be :output "static/{{ file }}", but that's outside of the output directory and so the stylesheets wouldn't be being served. Setting it to :output "output/static/{{ file }}" should fix the situation. Ie:

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