Coder Social home page Coder Social logo

org-static-blog's Introduction

ORG-STATIC-BLOG

http://melpa.org/packages/org-static-blog-badge.svg http://stable.melpa.org/packages/org-static-blog-badge.svg

Static blog generators are a dime a dozen. This is one more, which focuses on being simple. All files are simple org-mode files in a directory. The only requirement is that every org file must have a #+TITLE and a #+DATE, and optionally, #+FILETAGS, #+DESCRIPTION and #+IMAGE.

#+FILETAGS set the tags for the post, which can be delimited by colons in the form of #+FILETAGS: :foo bar:baz:, or by whitespaces in the form of #+FILETAGS: foo bar. And you can put a short summary in #+DESCRIPTION, which will be converted to a HTML <meta name="description" > tag, it’s good for SEO as described in Wikipedia’s Meta element.

If org-static-blog-enable-og-tags is set to t, #+DESCRIPTION and #+IMAGE (it must be e a relative url) will generate the og:description and og:image meta properties that will be used in URL previews generated in social networks and similar sites (see Open Graph Protocol).

This file is also available from marmalade and melpa-stable.

Set up your blog by customizing org-static-blog’s parameters, then call M-x org-static-blog-publish to render the whole blog or M-x org-static-blog-publish-file filename.org to render only only the file filename.org.

Above all, I tried to make org-static-blog as simple as possible. There are no magic tricks, and all of the source code is meant to be easy to read, understand and modify.

For org-static-blog, a blog consists of six parts:

  • Blog posts contain individual entries. Every org file in org-static-blog-posts-directory is one blog post. Each blog post is rendered as its own HTML page.
  • The index page contains the last few blog posts on a single page. The number of entries on the index page can be customized using org-static-blog-index-length.
  • Optionally show a preview of the post (instead of the full post) on the index page setting org-static-blog-use-preview to t. The region of the post used as a preview is, by default, its first paragraph, but can be fine-tuned using org-static-blog-preview-start and org-static-blog-preview-end.
  • The archive page lists the publishing dates and headlines of every blog post.
  • The RSS feed is a machine-readable XML file that contains every blog post. It is not meant to be consumed by humans. Instead RSS readers can use the RSS feed to aggregate entries from multiple blogs.
  • Drafts are rendered like regular blog posts, but are not included in the index, the archive, or the RSS feed.
  • Each blog post can be tagged, and each tag links to a page that lists all other posts of the same tag. Additionally, a tag overview page is created that lists the publishing dates and headlines of every blog post, sorted by tags. This feature is only enabled if you set org-static-blog-enable-tags to t.
  • If org-static-blog-enable-og-tags is set to t, all generated pages will include some useful Open Graph meta properties such as the title, the description and an optional image. If no #+IMAGE property is provided in a post, the default one specified in org-static-blog-image will be used.
  • To disable comments for single blog posts, reserve a tag name as org-static-blog-no-comments-tag and tag the post with that tag.
  • It is also possible to create per-tag RSS feeds. This feature is only enabled when you set org-static-blog-enable-tag-rss to t.

Every HTML page in org-static-blog can be customized in the following ways:

  • The contents of org-static-blog-page-header are inserted into the <head> of every page. Use this to include custom CSS and JavaScript for your blog.
  • The contents of org-static-blog-page-preamble is inserted just before the content of every page. This is a good place to put the header or menus for your blog.
  • The contents of org-static-blog-page-postamble is inserted after the content of every generated page: after any blog post page, after the index page, the tag pages and the archive. This is where you can include copyright notices.
  • The return values of org-static-blog-post-preamble and org-static-blog-post-postamble are prepended and appended to every blog post. If you want to change the formatting of dates, titles, or the tag list, overwrite these functions. In particular the content of org-static-blog-post-comments is inserted at the end of each blog post. Use this to add a comment box.

You can customize the RSS feed output by setting org-static-blog-rss-extra. Its content is placed right before the sequence of posts. For example you can add an RSS icon for the feed, or advertise that you built your blog with org-static-blog. You can also limit the number of entries in the feed via org-static-blog-rss-max-entries.

There are some static texts like ”Other posts”, ”Tags” etc that org-static-blog includes in produced html. By default org-static-blog uses english texts, but language chosen depends on value set to org-static-blog-langcode. If your language is not supported yet, you will see placeholders like [other-posts:de] and [tags:de]. You can add new language by adding texts to org-static-blog-texts list. And if you do, please share and create Pull Request.

If you want to activate a few convenience key bindings, add (add-to-list 'auto-mode-alist (cons (concat org-static-blog-posts-directory ".*\\.org\\'") 'org-static-blog-mode)) to your init.el. These key bindings are:

  • C-c C-f / C-c C-b to open next/previous post.
  • C-c C-p to open the matching published HTML file of a post.
  • C-c C-n to create a new blog post.

If you have questions, if you find bugs, or if you would like to contribute something to org-static-blog, please open an issue or pull request on GitHub.

Finally, I would like to remind you that I am developing this project for free, and in my spare time. While I try to be as accommodating as possible, I can not guarantee a timely response to issues. Publishing Open Source Software on GitHub does not imply an obligation to fix your problem right now. Please be civil.

Examples

Minimal Configuration

This minimal configuration should be added to your init.el, and will set up a minimal org-static-blog for the URL https://staticblog.org, which will be saved in the directory ~/projects/blog/.

(setq org-static-blog-publish-title "My Static Org Blog")
(setq org-static-blog-publish-url "https://staticblog.org/")
(setq org-static-blog-publish-directory "~/projects/blog/")
(setq org-static-blog-posts-directory "~/projects/blog/posts/")
(setq org-static-blog-drafts-directory "~/projects/blog/drafts/")
(setq org-static-blog-enable-tags t)
(setq org-export-with-toc nil)
(setq org-export-with-section-numbers nil)

;; This header is inserted into the <head> section of every page:
;;   (you will need to create the style sheet at
;;    ~/projects/blog/static/style.css
;;    and the favicon at
;;    ~/projects/blog/static/favicon.ico)
(setq org-static-blog-page-header
      "<meta name=\"author\" content=\"John Dow\">
<meta name=\"referrer\" content=\"no-referrer\">
<meta name=\"viewport\" content=\"initial-scale=1,width=device-width,minimum-scale=1\">
<link href= \"static/style.css\" rel=\"stylesheet\" type=\"text/css\" />
<link rel=\"icon\" href=\"static/favicon.ico\">")

;; This preamble is inserted at the beginning of the <body> of every page:
;;   This particular HTML creates a <div> with a simple linked headline
(setq org-static-blog-page-preamble
      "<div class=\"header\">
  <a href=\"https://staticblog.org\">My Static Org Blog</a>
</div>")

;; This postamble is inserted at the end of the <body> of every page:
;;   This particular HTML creates a <div> with a link to the archive page
;;   and a licensing stub.
(setq org-static-blog-page-postamble
      "<div id=\"archive\">
  <a href=\"https://staticblog.org/archive.html\">Other posts</a>
</div>
<center><a rel=\"license\" href=\"https://creativecommons.org/licenses/by-sa/3.0/\"><img alt=\"Creative Commons License\" style=\"border-width:0\" src=\"https://i.creativecommons.org/l/by-sa/3.0/88x31.png\" /></a><br /><span xmlns:dct=\"https://purl.org/dc/terms/\" href=\"https://purl.org/dc/dcmitype/Text\" property=\"dct:title\" rel=\"dct:type\">bastibe.de</span> by <a xmlns:cc=\"https://creativecommons.org/ns#\" href=\"https://bastibe.de\" property=\"cc:attributionName\" rel=\"cc:attributionURL\">Bastian Bechtold</a> is licensed under a <a rel=\"license\" href=\"https://creativecommons.org/licenses/by-sa/3.0/\">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</center>")

;; This HTML code is inserted into the index page between the preamble and
;;   the blog posts
(setq org-static-blog-index-front-matter
      "<h1> Welcome to my blog </h1>\n")

In order for this to work, you will also need to create a style sheet at ~/projects/blog/static/style.css, which might for example change the appearance of the #preamble, the #content, and the #postamble.

To write posts, you can now call org-static-blog-create-new-post, and render your blog with org-static-blog-publish.

Each post is an org-mode file such as

#+title: How to Write a Blog Post
#+date: <2020-07-03 08:57>
#+filetags: computers emacs blog

Step one: Install ~org-static-blog~. \\
Step Two: Execute ~M-x org-static-blog-create-new-post~ and write the content. \\
Step Three: Execute ~M-x org-static-blog-publish~ and upload to your webhost. \\
Done.

You can find more complete examples by looking at my init.el and the repository for my blog (bastibe.de) itself to see an example of how to use org-static-blog in practice.

Other org-static-blog blogs:

Features

Hide some subtrees when publishing

  • Background When publishing some posts, we may not want to publish the more private or unfinished parts of the subtrees. So maybe we can use tags to identify these subtrees and ignore them during the posting process.
  • Usage
    • Set the corresponding tags Set the tag to ignore subtrees with org-static-blog-no-post-tag, default is nonpost.
    • Posting The parts containing this tag will be automatically ignored during the posting process.
  • Example
    • If you have an org-mode file containing tree-1, tree-2, tree-3. and only want to publish tree-1 and tree-3, then the file would look like this
    * tree-1
    * tree-2 :nonpost:
    * tree-3
        
    • Then the file will automatically ignore tree-2 subtrees with the nonpost tag when it is published.

Extended cleaning of the suggested filename

If you regularly find yourself editing the suggested filename when creating new posts, e.g. replacing slashes (`/`), then you can modify the value of `org-static-blog-suggested-filename-cleaning-regexp`. With its default value, `”\s”`, it only replaces whitespace.

For example, a post with the title “Using bastibe/org-static-blog for your blog” would, with the default result in a suggested filename of `2023-10-02-using-bastibe/org-static-blog-for-your-blog.org`. If the value of `org-static-blog-suggested-filename-cleaning-regexp` is changed like this

“` (setq org-static-blog-suggested-filename-cleaning-regexp (rx (or “/” (in white))) “`

the `/` will be replaced too and the suggested filename will be `2023-10-02-using-bastibe-org-static-blog-for-your-blog.org`.

Known Issues

  • Org-static-blog is a pure static site generator. As such, it does not include comments. However, you can easily include services like Disqus to do this for you.
  • You can have hosting services like GitHub auto-render you blog every time you commit using continuous integration tools like Travis CI. An example of how to do this has been gracefully provided by zngguvnf.
  • Individual blog entries are only re-rendered if no current HTML file is available (i.e. the org file is older than the HTML file). If you want to forcibly re-render an entry, delete the HTML file.

Changelog

  • 2018-03-17 (v1.0.4): Massive speed up of org-static-blog. A re-render with one changed file used to take about a second per post, and now takes about a second total.
  • 2018-03-21 (v1.1.0): Tags. Each post can now have tags (using #+tags:). If you enable org-static-blog-enable-tags, tags are included in each post, tag-index pages are generated for each tag, and a tag archive is generated for all tags.
  • 2018-03-23 (v1.1.1): Tags. Deprecated #+tags: in favor of #+filetags:, which is the correct way of setting file-wide tags in org-mode. (Thank you, Kaushal Modi!)
  • 2018-04-19 (v1.2.0): HTML5 Org-static-blog now outputs valid HTML5 instead of XHTML. This makes the resulting HTML cleaner, but shouldn’t impact your styles. Also, you can now customize your content language by setting org-static-blog-langcode and the HTML output has been fixed in a few places. (Thank you, Michael Cardell Widerkrantz!)
  • 2020-03-20 (v1.3.0): Nested directories, Translations, and more Improve handling of local variables (Thank you, Matthew Bauer) Rewrote README in org-mode (Thank you, Rafał -rsm- Marek) Adds support for localizations (Thank you, Rafał -rsm- Marek) Put license in a LICENSE file (Thank you, Jonas Bernoulli) Adds uption to force-rerender entire blog (Thank you, Winny) Support for non-flat directory structure (Thank you, Shmavon Gazanchyan) Support for “preview” slugs on index page (Thank you, K. Scarlet) Various bugfixes (Thank you, Matthew Bauer, luhuaei, neeasade, Yauhen Makei, Winny, zsxh) Translations in RU, BY, FR (Thank you, Yauhen Makei, Théo Jacquin)
  • 2020-07-20 (v1.4.0): Adds a command to create drafts (Thank you, Massimo Lauria) Adds optional RSS info (Thank you, Massimo Lauria) Restructures preamble and postamble to be more consistent (Thank you, Massimo Lauria) Translations in IT, ES (Thank you, Massimo Lauria, Alberto Álvarez) Option to make ellipsis link to full post (Thank you, jaor) Improves preview generation (Thank you, Allo) Render RSS dates as per RFT-822 and the RSS spec
  • 2021-03-05 (v1.5.0) Better awareness for posts in subdirectories (Thank you, Justin Abrahms) New custom variable org-static-blog-rss-max-entries (Thank you, jao) Can now exclude some posts from RSS feeds (Thank you, jao) New custom variable for index page header (Thank you, Bruno Deremble)
  • 2022-05-05 (v1.6.0) Adds #+description support that fills the description meta tag (Thank you, Guangwang Huang) Adds optional post slugs, and date before title (Thank you, jao) Correct date encoding in RSS and various RSS fixes (Thank you, Agnessa Bubowska) Ability to not publish subtrees by tag (Thank you, wangz) Fixes some warnings related to Emacs 28 (Thank you, Maciej Barć)
  • next Fixes path related issues for drafts Optionally disables comments if a customizable tag is set

LICENSE

Copyright 2015, Bastian Bechtold

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

org-static-blog's People

Contributors

adithyaov avatar aeghn avatar alhassy avatar bastibe avatar bderembl avatar djgoku avatar frederic-santos avatar hellwolf avatar hughjfchen avatar jaor avatar justinabrahms avatar kchanqvq avatar ladykosha avatar luhuaei avatar magthe avatar massimolauria avatar matthewbauer avatar mchackorg avatar mungell avatar neeasade avatar nukosuke avatar petergil avatar proofconstruction avatar snickerbockers avatar unmonoqueteclea avatar whatacold avatar winny- avatar xgqt avatar zngguvnf avatar zsxh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

org-static-blog's Issues

Get rid of links on standalone pages

I don't want to have links which go to the same page, like each blog plost's <h1> is a link to itself.
Is it possible to remove them?
UPD:
I tried to remove them, but it also removed them from index page

org-static-blog-publish wrong

Hi, When I exec org-static-blog-publish, prompt wrong apply: Wrong type argument: sequencep, org-static-blog-assemble-tags-archive-tag.

Finally discover the (apply 'concat (mapcar tag-tree 'org-static-blog-assemble-tags-archive-tag)) error

Modify to (apply 'concat (mapcar 'org-static-blog-assemble-tags-archive-tag tag-tree)) ;)

unsupport chinese date format

error stack as below

signal(error ("Invalid date: 2017-09-26 周二"))
error("Invalid date: %s" "2017-09-26 周二")
date-to-time("2017-09-26 周二")
org-static-blog-get-date("d:/Documents/MyProject/......")
org-static-blog-get-post-public-path("d:/Documents/MyProject/......")
org-static-blog-matching-publish-filename("d:/Documents/MyProject/......")
org-static-blog-needs-publishing-p("d:/Documents/MyProject/......")
org-static-blog-publish(nil)

HTML5 semantic elements

Would you be open to accept a pull request that changes the HTML output to use semantic elements? That is, an index page with elements like:

<header></header>
<nav></nav>
<main>
<article>
</article>
<article>
</article>
</main>
<footer>
</footer>

And perhaps using <time> for all dates.

This could be done either as a replacement for most of the <div> tags or, if that is too controversial, perhaps a multi-stage merge: 1) Adding all the semantic elements without touching div's, 2) Warning all current users about the imminent removal of div's, 3) Remove unnecessary divs's.

What do you think?

Drafts are published to directory relative to posts directory instead of drafts directory

After the update in #83 draft entries are published to their position relative to the post directory since the new implementation does not take drafts into account.

This means that if you have

(setq org-static-blog-publish-directory "~/projects/blog/")
(setq org-static-blog-posts-directory "~/projects/blog/posts/")
(setq org-static-blog-drafts-directory "~/projects/blog/drafts/")

(like in the readme setup) and a draft named ~/projects/blog/drafts/test.org the html file that will be generated is ~/projects/blog/../drafts/test.html.

A simple (but not elegant) fix would be to just do something like

(let ((post-base-dir (cond ((string-prefix-p org-static-blog-posts-directory post-filename) org-static-blog-posts-directory)
                           ((string-prefix-p org-static-blog-drafts-directory post-filename) org-static-blog-drafts-directory))))
  (concat (file-name-sans-extension (file-relative-name post-filename post-base-dir))
	      ".html"))

instead.

org-static-blog created a page from the wrong file

Hello -- I had an org buffer named rice.org open somewhere that was not related to my drafts-dir (abusing for static pages) rice.org file. When I generated my site, the open buffer of that name got scooped and generated instead of the intended draft page org source file. Just a gotcha to be aware of

new release

Could we get a new release? The last one is going to be 2 years ago and more than half of the total commits (67) aren't incorporated in a release yet.

For blog sources and sites isolation

Hi, the plugins can provide a variable name like org-static-blog-sources-directory to point to blog sources, and org-static-blog-sources-posts-directory,org-static-blog-sources-drafts-directory, let blog source and generated sites store in different folders, also let create drafts function available, let we can decide the drafts want to post to blog or not.

Change URL patterns

I've never used org-static-blog and I just started porting my blog (which uses only org-export).
I'm a Emacs beginner but, copying snippets of code around the web, I was able to write this:

(defun my-org-export-output-file-name (orig-fun extension &optional subtreep pub-dir)
  (if (string-match "posts/\\'" pub-dir)
      (let ((path (buffer-file-name (buffer-base-buffer))))
	(save-match-data (and (string-match "posts/\\([^@]+\\)\\.org\\'" path)
			      (setq filename (match-string 1 path))))
	(if (equal filename "index")
	    (concat pub-dir "/index.html")
	  (progn
	    (make-directory (concat pub-dir filename))
	    (concat pub-dir filename "/index.html")
	    )))
    (apply orig-fun extension subtreep pub-dir nil)))

(advice-add 'org-export-output-file-name :around #'my-org-export-output-file-name)

The idea is that if I have a post file my-post.org then it should be published as https://myblog.com/posts/my-post/index.html.
One problem, for example, is that org-static-blog creates pages for the tags, there should be need of an analogue for the tags.
Moreover, since I don't know this project, I don't think I can predict all the related issues.
So before I try to invent a not so elegant workaround I would like to know if:

  1. is there already a way using org-static-blog?
  2. is there interest to have a way? In the case, if I succeed doing this in a decent way I could consider a pull request.

dir-locals aren't being applied

I have a .dir-locals.el file in the root of my blog that looks like this:

;;; Directory Local Variables
;;; For more information see (info "(emacs) Directory Variables")

((nil
  (org-static-blog-page-preamble . "<h1><a class=\"name\" href>Matthew Bauer</a> ◌ <a href=\".\">Blog</a> ◌ <a class=\"name\" href=\"feed.xml\">RSS</a></h1>")
  (org-static-blog-publish-title . "Matthew Bauer’s Blog")
  (org-static-blog-publish-url . "https://matthewbauer.us/blog/")
  (org-static-blog-rss-file . "feed.xml")
  (org-static-blog-index-length . 1)
  (org-static-blog-page-header . "  <meta name=\"author\" content=\"Matthew Bauer\">
  <meta name=\"viewport\" content=\"initial-scale=1,width=device-width,minimum-scale=1\">
  <link rel=\"stylesheet\" href=\"../style.css\">")))

They don't seem to be used by org-static-blog-publish. The values are set in the buffer, but org-static-blog uses the custom one for some reason.

Mathjax?

Hey - I was expecting the default org export behaviour of adding a script tag to import mathjax and some settings when latex support is needed on a page, but I notice that this doesn't happen with the static blog?

Is this deliberate? Can/should it be fixed?

Annoying warnings

I've got some annoying warnings related to the postamble part when I publish any org file

(setq org-static-blog-page-postamble
"<div id="archive">
<a href="https://user.codeberg.page/rss.html\">RSS

\"Creative


user.com by user is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.

If you want to contact me, this is my email address:

<a href="mailto:[email protected]">VRFdS

")

Warnings buffer

line 242 column 149 - Warning: escaping malformed URI reference
line 242 column 413 - Warning: escaping malformed URI reference
line 250 column 1 - Warning: escaping malformed URI reference
line 250 column 1 - Warning: illegal characters found in URI
line 245 column 1 - Warning:

element removed from HTML5
line 248 column 1 - Warning: proprietary attribute "xmlns:dct"
line 248 column 1 - Warning: proprietary attribute "href"
line 250 column 1 - Warning:
proprietary attribute "xmlns:cc"

How can I fix these warnings?
Because Emacs splits into two windows and opens up a new warning window buffer every time I publish an org file.

Also, I think that the image from this link is broken:
<a rel="license"href="https://creativecommons.org/licenses/by-sa/3.0/\"><img alt="Creative Commons License"
style="border-width:0"
src="https://i.creativecommons.org/l/by-sa/3.0/20x10.png\"

static pages

Can I have static pages besides the posts ? In other words, can it be used to create a personal website ?

Thanks

Hello Bastian,

Just wanted to say thanks for providing us with this excellent bit of software. I have tried many alternatives (e.g. Nikola) but this was by far the simplest solution that was most easy to configure.

As a suggestion to other users: I (ab)use drafts as static pages. For example, I have a drafts/index.org that becomes my landing page (after changing org-static-blog-index-file to "blog.html").

For more, have a look at my setup for github pages at https://github.com/otech-nl/otech-nl.github.io/

Regards,

René

Support non-flat directory structure

It would be nice to use directory-files-recursively instead of directory-files and allow subdirectories of arbitrary depth inside org-static-blog-posts-directory. This would allow having example.com/2018/test.html instead of e.g. example.com/2018-test.html.

Relative links for images in RSS output

Hi,

I have an issue generating a proper RSS.

I am using org-mode version 9.2.6 and org-static-blog 1.3.0 and my configuration includes

(setq org-static-blog-publish-url "https://example.com/subfolder/")
(setq org-static-blog-publish-directory "~/blog/"))

If the blog post contains an image which for example is originally included as [[file:assets/image.jpg]] in the org file, I obtain

<img src="assets/image.jpg"> 

in both the HTML and the RSS output. But in the latter case this seems to be an issue, because I cannot see the images of the post in any RSS reader. Furthermore similar issues apply to the footnote links.

Reading the pages from the browser is fine since relative links are fine there. I am afraid that producing the RSS export just by cutting and pasting the HTML export is not the correct way.

Best,

Add small example blog

Any chance that you could add a small example blog directory to help newbies get going? Many thanks in advance!

bytecomp warnings when starting emacs, any help?

I got this output when starting emacs but have no clue about fixing if so, any help on this, please?? I'd appreciate it.

Warning (bytecomp): defcustom for ‘org-static-blog-publish-url’ fails to specify type [2 times]
Warning (bytecomp): defcustom for ‘org-static-blog-publish-title’ fails to specify type [2 times]
Warning (bytecomp): defcustom for ‘org-static-blog-publish-directory’ fails to specify type [2 times]
Warning (bytecomp): defcustom for ‘org-static-blog-posts-directory’ fails to specify type [2 times]
Warning (bytecomp): defcustom for ‘org-static-blog-drafts-directory’ fails to specify type [2 times]
Warning (bytecomp): defcustom for ‘org-static-blog-index-file’ fails to specify type [2 times]
Warning (bytecomp): defcustom for ‘org-static-blog-index-length’ fails to specify type [2 times]
Warning (bytecomp): defcustom for ‘org-static-blog-archive-file’ fails to specify type [2 times]
Warning (bytecomp): defcustom for ‘org-static-blog-tags-file’ fails to specify type [2 times]
Warning (bytecomp): defcustom for ‘org-static-blog-enable-tags’ fails to specify type [2 times]
Warning (bytecomp): defcustom for ‘org-static-blog-enable-deprecation-warning’ fails to specify type [2 times]
Warning (bytecomp): defcustom for ‘org-static-blog-rss-file’ fails to specify type [2 times]
Warning (bytecomp): defcustom for ‘org-static-blog-page-header’ fails to specify type [2 times]
Warning (bytecomp): defcustom for ‘org-static-blog-page-preamble’ fails to specify type [2 times]
Warning (bytecomp): defcustom for ‘org-static-blog-page-postamble’ fails to specify type [2 times]
Warning (bytecomp): defcustom for ‘org-static-blog-langcode’ fails to specify type [2 times]
Warning (bytecomp): defcustom for ‘org-static-blog-use-preview’ fails to specify type [2 times]
Warning (bytecomp): defcustom for ‘org-static-blog-preview-convert-titles’ fails to specify type [2 times]
Warning (bytecomp): defcustom for ‘org-static-blog-preview-ellipsis’ fails to specify type [2 times]

Overwrites other buffers called index.html

Alright, I think I've got a bug.

In my current set-up of a very simple static site I run, I have the site's main index in the root directory, and the output of org-static-blog in a subdirectory:

sitename\index.html
sitename\blog\index.html

Say that I am editing sitename\index.html. I finish my edit, and save the buffer -- but don't kill the buffer.

Say that I then write a new blog post, and save that buffer to sitename\blog\posts\newpost.org

If I then run org-static-blog-publish to build the blog, without killing the buffer containing sitename\index.html, then org-static-blog-publish incorrectly overwrites the contents of the sitename\index.html buffer with the code that should be going into the file at sitename\blog\index.html. The process then automatically saves the result, which essentially destroys the original file.

I thought for a while that I'd just misconfigured the folders, but discovered this morning that this appears to happen regardless of where I put the index.html file that I'm editing.

So, for example, from a new Emacs session where I haven't done anything yet, if I create a new buffer and save it as:

sitename\blog\bug\hello\test\index.html

And then immediately run org-static-blog-publish -- as long as I haven't killed the sitename\blog\bug\hello\test\index.html buffer, the file will be overwritten and saved in that weird location. The index file in sitename\blog\index.html will be untouched.

I don't know enough about Elisp to know if this is even fixable -- and the obvious solution is "kill your index buffer before building the blog" -- but I thought maybe you should know.

Cannot output files to blog directory

I have not been able to set up org-static-blog correctly. After doing org-static-blog-publish, it doesn't output any file to the blog directory. Below is what I have in my .emacs file. I essentially copy and paste from the example from org-static-blog website.

(use-package org-static-blog
  :ensure t
  :config
  (setq
   org-static-blog-publish-title "My Static Org Blog"
   org-static-blog-publish-url "https://staticblog.org/"
   org-static-blog-publish-directory "~/git/www/nguyenthanhvuh/docs/myblog/"
   org-static-blog-posts-directory "~/git/www/nguyenthanhvuh/docs/myblog/posts/"
   org-static-blog-drafts-directory "~/git/www/nguyenthanhvuh/docs/myblog/drafts/"
   org-static-blog-enable-tags t
   org-export-with-toc nil
   org-export-with-section-numbers nil

   ;; This header is inserted into the <head> section of every page:
   ;;   (you will need to create the style sheet at
   ;;    ~/projects/blog/static/style.css
   ;;    and the favicon at
   ;;    ~/projects/blog/static/favicon.ico)
   org-static-blog-page-header
   "<meta name=\"author\" content=\"John Dow\">
<meta name=\"referrer\" content=\"no-referrer\">
<link href= \"static/style.css\" rel=\"stylesheet\" type=\"text/css\" />
<link rel=\"icon\" href=\"static/favicon.ico\">"
  
   ;; This preamble is inserted at the beginning of the <body> of every page:
   ;;   This particular HTML creates a <div> with a simple linked headline
   org-static-blog-page-preamble
   "<div class=\"header\">
  <a href=\"https://staticblog.org\">My Static Org Blog</a>
</div>"

   ;; This postamble is inserted at the end of the <body> of every page:
   ;;   This particular HTML creates a <div> with a link to the archive page
   ;;   and a licensing stub.
   org-static-blog-page-postamble
   "<div id=\"archive\">
  <a href=\"https://staticblog.org/archive.html\">Other posts</a>
</div>
<center><a rel=\"license\" href=\"https://creativecommons.org/licenses/by-sa/3.0/\"><img alt=\"Creative Commons License\" style=\"border-width:0\" src=\"https://i.creativecommons.org/l/by-sa/3.0/88x31.png\" /></a><br /><span xmlns:dct=\"https://purl.org/dc/terms/\" href=\"https://purl.org/dc/dcmitype/Text\" property=\"dct:title\" rel=\"dct:type\">bastibe.de</span> by <a xmlns:cc=\"https://creativecommons.org/ns#\" href=\"https://bastibe.de\" property=\"cc:attributionName\" rel=\"cc:attributionURL\">Bastian Bechtold</a> is licensed under a <a rel=\"license\" href=\"https://creativecommons.org/licenses/by-sa/3.0/\">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</center>"
   
   ;; This HTML code is inserted into the index page between the preamble and
   ;;   the blog posts
   org-static-blog-index-front-matter
   "<h1> Welcome to my blog </h1>\n")
  )

Publish not working all the time

I'm having issues with org-static-blog-publish failing with the following error message every now and then.

helm-M-x-execute-command: Wrong type argument: stringp, nil

There seems to be no pattern to it failing. Am I alone in seeing this? My experience with elisp is limited, so where should I start trying to debug this?

My config looks like this

(setq
 org-static-blog-drafts-directory "~/Private/tmp/tst-org-static/drafts"
 org-static-blog-enable-tag-rss t
 org-static-blog-enable-tags t
 org-static-blog-posts-directory "~/Private/tmp/tst-org-static/posts"
 org-static-blog-publish-directory "~/Private/tmp/tst-org-static"
 org-static-blog-publish-title "Magnus web site"
 org-static-blog-publish-url "https://magnus.therning.org/"
 org-export-with-toc nil
 org-export-with-section-numbers nil
 )

My (org-version): 9.4.4

org-blog-static-mode should be a minor mode.

Since all the mode does is to set few keybindings, I don't see the point of having the mode to be a major mode derived from org-mode. It would be cleaner to make it a minor mode. In this way the user would be able to create posts (and drafts, see my PR #52) from any buffer, as long as the minor mode is active.

Use of absolute/relative URLs

Continued from #37

The reason for the absolute URLs in org-static-blog is that we avoid re-exporting posts as much as possible. We do this by rendering each page once, and simply copying content from the posts to the summary pages (index, rss). If we don't do this, org-static-blog-publish takes ages (as it did in the past).

I'm open to suggestions, though.

ox-tufte as a "template" ?

Hi.
Thank you for your work. I’m planning to make use of it for my blog

Wondered.. Do you think of any trivial way to integrate ox-tufte as a «template» ?
This is alas totally beyond my «hacking» skills.

Tagged feeds

Hi,

First off thanks for making this! This is the best blogging solution in org I've been able to find and it's very easy to use.

One feature I would find useful is being able to build up indexes for different tagged post. So I want to be able to have a .xml file (and maybe archive) that lists all of my posts with one tag (say org related posts) and be able to put that in the feed reader. Seems like it should be possible but I haven't been able to look into it yet.

"#+date:" regex search fails when foreign newline characters are present

Hello! Thanks for the upgrade to the build process. It's much improved! I've got an unusual bug for you, though -- or maybe just an FYI?

I wrote a post on a Windows machine in Notepad (it was all I had at the time). I sent it to my posts folder, and tried to run org-static-blog-publish as usual remotely, without looking at the file first. I received the following error:

let: Search failed: "^\\#\\+date:[ ]*<\\([^]>]+\\)>$"

I re-ran the publish operation immediately without bothering to make any changes to anything, because that's how computers work, as we all know, and it gave me the slightly different error:

progn: Search failed: "^\\#\\+date:[ ]*<\\([^]>]+\\)>$"

I checked my config -- I know you've done a few releases this week -- but everything still looked good.

Turns out, those pesky \M newline characters from Windows in my post were hosing the search function you're running. Replaced the newlines, saved, and org-static-blog-publish completed correctly.

list of org-static-blog sites?

I'm enjoying the ease of blogging with org-static-blog, but of course now I want to tinker with the css styles. Is there a list of blogs that use this, or some unique string in o-s-b pages I could search for?

Images and other files support

Right now when I add an image in a post via org-mode markup:

#+name: Drawing
#+caption: Test figure
[[file:drawing.svg]]

I get:

<figure id="org25aec15">
<object type="image/svg+xml" data="drawing.svg" class="org-svg">
Sorry, your browser does not support SVG.</object>

<figcaption><span class="figure-number">Figure 1: </span>Test figure</figcaption>
</figure>

Which is... broken because the path is relative to org-static-blog-posts-directory and not org-static-blog-publish-directory.

I do not want to write my blog post with relative links to org-static-blog-publish-directory because it would break the file search to insert files as well as image previews.

A simple way to solve this (by no mean the only one nor the best) would be to copy (or link ?) files from org-static-blog-post-directory to org-static-blog-publish-directory if they match a given patttern (*.png, *.jpg, *.svg... we make the exact pattern a customize option).

What do you think ?

Allow org babel file output to work

eg:

#+title: this is a big ole test post
#+date: <2009-03-05 13:55>

test graph

#+BEGIN_SRC dot :file dist/dot_test.png
digraph G {
  lisp -> common_lisp;
  lisp -> scheme;
}
#+END_SRC

create the file dist/dot_test.png, like it does when I org-html-export-to-html.

edit: thank you for this project, it is nice.

Wrong type argument: listp, #("Welcome" 0 7 (:parent (#0))) error

When I issue a M-x org-static-blog-publish I receive the error:

Wrong type argument: listp, #("Welcome" 0 7 (:parent (#0)))

Contents of 2019-01-08-welcome.org:

#+title: Welcome
#+date: <2019-01-08 23:04>
#+filetags: news

Example blog entry text here

Forgive my ignorance but I'm not sure what I've done wrong here. No html is being exported. I'm using Emacs 25.2.2, Org 9.2 and org-static-blog 1.2.1. Are my Emacs and Org versions too new?

Generated blog posts goes to "example.com/$file-name"

my emacs configuration has the following

(setq org-static-blog-publish-title "Biel\'s Webpage")
(setq org-static-blog-publsh-url "0xbiel.vercel.app")
(setq org-static-blog-publish-directory "~/proj/fun/orw/public")
(setq org-static-blog-posts-directory "~/proj/fun/orw/posts/")
(setq org-static-blog-drafts-directory "~/proj/fun/orw/drafts/")
(setq org-static-blog-enable-tags t)
(setq org-export-with-toc t)
(setq org-export-with-section-numbers nil)

(setq org-static-blog-page-header
"<meta name=\"author\" content=\"Biel A. P.\">
<meta name=\"referrer\" content=\"no-referrer\">
<link href= \"static/style.css\" rel=\"stylesheet\" type=\"text/css\" />
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">")

but when I generate the blog posts using org-static-blog-publish, go to the website and click into the blog post link, it goes to https://example.com/2021-05-08-hello.html. How can I edit this url?

Missing </div> when index.html is generated with org-static-blog-enable-tags set to nil

When index.html is generated with org-static-blog-enable-tags set to nil an empty taglist is generated, leading to elements <div class="taglist"> being generated without a corresponding </div>

Sorry for bombing your tracker, I wouldn't have come across this issue if I hadn't run into the previous one. Needless to say, I'm loving how usable org-static-blog is and intend to use it when blogging inspiration strikes

Unknown "nil" back-end: Aborting export

Hi there! very nice project!

I have used your lib some time ago and I tried to use on a recently install but I got this message

org-export-barf-if-invalid-backend: Unknown "nil" back-end: Aborting export

I tried to toy a little bit with the code but it seems to be a missing piece on my end. Any ideas what it could be?

emacs version: 27.2
org version: 9.4.6

Thx!

Show only post titles in multipost pages (no preview, no contents)

Hello @bastibe and thank you for this package!

I have noticed that when setting org-static-blog-use-preview to nil, the produced archive page includes the complete file contents. The code for that is in org-static-blog-assemble-multipost-page:

    (apply 'concat (mapcar
                    (if org-static-blog-use-preview
                        'org-static-blog-get-preview
                      'org-static-blog-get-post-content)
                    post-filenames))

Do you think we can make this behaviour configurable? The idea is to only display titles without any further contents.

customize index page

Hi there,
great package thank you.

I was wondering if one could customize the index page a bit like adding a description of the blog just below the header.

maybe a pinned post (without the date)?
thanks

Backend unset or broken: `org-export-barf-if-invalid-backend: Unknown "nil" back-end: Aborting export`

Went to publish my newly generated site, and received the error: org-export-barf-if-invalid-backend: Unknown "nil" back-end: Aborting export.

  signal(error ("Unknown \"nil\" back-end: Aborting export"))
  error("Unknown \"%s\" back-end: Aborting export" nil)
  org-export-barf-if-invalid-backend(nil)
  org-export-as(org-static-blog-post-bare nil nil nil nil)
  org-static-blog-render-post-content("~/User/Site/posts/2022-11-03-fir...")
  org-static-blog-publish-file("~/User/Site/posts/2022-11-03-fir...")
  org-static-blog-publish(nil)
  funcall-interactively(org-static-blog-publish nil)
  call-interactively(org-static-blog-publish record nil)
  command-execute(org-static-blog-publish record)
  execute-extended-command(nil "org-static-blog-publish" nil)
  funcall-interactively(execute-extended-command nil "org-static-blog-publish" nil)
  call-interactively(execute-extended-command nil nil)
  command-execute(execute-extended-command)

Is there some crucial step that I missed?

Wrong number of arguments error when exporting with org-static-blog-enable-tags t

I'm using org-static-blog-20201117.906. I created the file

`#+title: First post
#+date: <2020-11-18 08:08>
#+filetags: test random

I am trying out org-static-blog for the first time. I want to blog a bit, and I like org so maybe this is the correct solution for me.`

and run org-static-blog-publish, which results in the error
org-static-blog-assemble-multipost-page: Wrong number of arguments: (lambda (dir filename) "Concat filename to another path interpreted as a directory." (concat (file-name-as-directory dir) filename)), 4

The post is correctly exported and the files archive.html, index.html, rss.xml, and tags.html are created correctly but tag-test.html and tag-random.html are not created.

All works correctly when org-static-blog-enable-tags is set to nil

Datetime strings in RSS feed are not properly RFC-822 formatted

My feed reader just tripped over the datetime strings used for lastBuildDate and pubDate in the RSS feed of your site, bastibe.de. Apparently format-time-string formats the dates according to the system locale, when not specified otherwise. Thus specifically the month of May comes back as Mai with a German locale setting, leading to an invalid feed:

https://validator.w3.org/feed/check.cgi?url=https%3A%2F%2Fbastibe.de%2Frss.xml

It should be ensured that settings LC_TIME=en, and (setq system-time-locale "en") are used when rendering.

Cheers 👋

Have `index.html` and other `html` files in different locations

From what I am seeing that currently all the html files are published in org-static-blog-publish-directory. I was wondering if it would be possible to instead just have the html files corresponding to the blog posts be published in the org-static-blog-publish-directory and the index.html file be published in the parent directory of org-static-blog-publish-directory?

Demote <h1> to <h2> on index page

A website should only have one <h1>. However, our index page currently contains every post in its entirity, including each posts <h1>.

Possible solutions:

  • keep as is.
  • demote <h1> to <h2>. Then we might have multiple levels of <h2> in a single post. We could make it look right in CSS, but it is structurally wrong.
  • demote all <hX> to <hX-1>. What to do about <h5>? This might break the layout.

Any other ideas?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.