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

Use of absolute/relative URLs #40

Open
bastibe opened this issue Sep 23, 2019 · 2 comments
Open

Use of absolute/relative URLs #40

bastibe opened this issue Sep 23, 2019 · 2 comments

Comments

@bastibe
Copy link
Owner

bastibe commented Sep 23, 2019

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.

@MunGell
Copy link
Contributor

MunGell commented Sep 23, 2019

Hi @bastibe

I believe there might be a misunderstanding of what @winny- was flagging as an issue in the closed PR.

My understanding is (and @winny- correct me if I am wrong) that the problem is in org-static-blog-get-absolute-url function, which prepends URLs with org-static-blog-publish-url.

org-static-blog-publish-url logically must contain domain name in it, which means that all links on the website are "hardcoded" to a specific domain.

Issues with such approach that @winny- mentioned:

  • It makes it inconvenient to work with the blog locally (need to change org-static-blog-publish-url to local address).
  • It makes website mirroring (or hosting on several domains) difficult.

Examples of where this function used:

My proposed solution is to separate the notion of org-static-blog-publish-url into:

  • org-static-blog-publish-domain - the domain of the blog, should be something like https://example.com (note: there is no slash in the end)
  • org-static-blog-publish-subdirectory - the subdirectory path to the blog website, e.g. /blog/ (note: needs slash in the end).

Example:

Say your blog is hosted on https://example.com/blog, then

  • org-static-blog-publish-domain = https://example.com
  • org-static-blog-publish-subdirectory = /blog

To make it all work we will need to update org-static-blog-get-absolute-url to use org-static-blog-publish-subdirectory instead of org-static-blog-publish-url:

Before:

(defun org-static-blog-get-absolute-url (relative-url)
  (concat org-static-blog-publish-url relative-url))

After:

(defun org-static-blog-get-absolute-url (relative-url)
  (concat org-static-blog-publish-subdirectory relative-url))

Backwards compatibility: we will need to change org-static-blog-publish-url to (concat org-static-blog-publish-domain org-static-blog-publish-subdirectory) in all the cases that are not related to URL generation.
For URL generation logic we will need to change org-static-blog-publish-url to org-static-blog-publish-subdirectory.

The default value of org-static-blog-publish-subdirectory should be set to /.

Hope it makes sense

@bastibe
Copy link
Owner Author

bastibe commented Sep 23, 2019

Ah, I see. I wasn't aware that you can have absolute URLs (/blog) that to not contain the domain (https://myblog.blog/blog). Sorry about the confusion.

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

2 participants