Code Monkey home page Code Monkey logo

emacs-easy-hugo's Introduction

easy-hugo melpa badge melpa stable badge License: GPL v3

logo

Emacs major mode designed for writing Hugo-powered blogs using various markup formats, including Markdown, Org-mode, AsciiDoc, reStructuredText, mmark, and HTML. It enhances the blogging experience within Emacs, making it easier to manage and create content.

Screencast

screencast

M-x easy-hugo

You can manage blogs on easy-hugo-mode. If you manage multiple blogs, you can switch blogs with the < or > key.

easy-hugo-mode

M-x easy-hugo-newpost

You can post a new article. Enter a article file name in the minibuffer. A markdown file is automatically generated. You can write a blog with markdown-mode.

easy-hugo4

If you enter '.org' file name in the minibuffer, org file is automatically generated and you can write a blog with org-mode.

easy-org-mode

If you enter '.ad' file name in the minibuffer, AsciiDoc file is automatically generated and you can write a blog with AsciiDoc.

easy-org-mode

If you enter '.rst' file name in the minibuffer, reStructuredText file is automatically generated and you can write a blog with reStructuredText.

easy-org-mode

If you enter '.mmark' file name in the minibuffer, mmark file is automatically generated and you can write a blog with mmark.

easy-org-mode

If you enter '.html' file name in the minibuffer, html file is automatically generated and you can write a blog with html.

easy-org-mode

M-x easy-hugo-preview

screencast

You can preview by following the edited part. When permalinks is hugo's default and English URL, if you press p with easy-hugo-mode, it displays a preview of the article on pointer.

easy-hugo6 (The picture of the header is http://www.pixiv.net/member_illust.php?mode=medium&illust_id=60674880)

The browser opens automatically and you can preview the blog on your laptop or desktop. Even if you run the easy-hugo-preview command many times, only one hugo process will run so do not mind it. Since the process of hugo running in the laptop or desktop disappears in 300 seconds, you do not have to worry about killing hugo process.

(setq easy-hugo-server-flags "-D")

Set easy-hugo-server-flags to -D in order to preview drafts.

M-x easy-hugo-publish

You can publish your blog to the server and the browser opens automatically.

M-x easy-hugo-publish-clever

Clever publish command. Automatically select the deployment destination from init.el. Only one command is executed in the following order. If easy-hugo-root is set the target blog, easy-hugo-publish will be executed. If easy-hugo-amazon-s3-bucket-name is set the target blog, easy-hugo-amazon-s3-deploy will be executed. If easy-hugo-google-cloud-storage-bucket-name is set the target blog, easy-hugo-google-cloud-storage-deploy will be executed. If the target blog has "deploy.sh" on easy-hugo-basedir, easy-hugo-github-deploy will be executed. If there is firebase command, easy-hugo-firebase-deploy will be executed.

M-x easy-hugo-ag

easy-hugo-helm-ag

You can search blog article with counsel-ag or helm-ag. If both are installed, counsel-ag takes precedence at default and you can use helm-ag by writing the following to .emacs or init.el.

(setq easy-hugo-helm-ag t)

If you deploy your blog at Firebase.

M-x easy-hugo-firebase-deploy

To use easy-hugo-firebase-deploy, you make project at firebase hosting using your browser. Next run command.

npm install -g firebase-tools
cd [your-hugo-directory]
firebase login
firebase init
firebase deploy

If you deploy your blog at github etc.

M-x easy-hugo-github-deploy

Execute deploy.sh which exists in directory easy-hugo-basedir. It is useful for hosting on GitHub Pages etc. When you create deploy.sh with reference to hosting, it can also correspond to various sites. For more GitHub Pages information refer to here and here. If you use .github/workflows/hugo.yaml, GitHub Actions will work, so you don't need deploy.sh.

M-x easy-hugo-magit

Netlify just press M and commit to GitHub. Please install Magit to use this feature.

M-x easy-hugo-amazon-s3-deploy

Deploy hugo source at Amazon S3.

M-x easy-hugo-google-cloud-storage-deploy

Deploy hugo source at Google Cloud Storage.

M-x easy-hugo-next-postdir
M-x easy-hugo-previous-postdir

With this you can go to a directory other than content/post.

M-x easy-hugo-select-filename

Select filename you want to open. You can open a selected filename article.

easy-hugo-select-filename

M-x easy-hugo-select-postdir

Select postdir you want to go. You can go to a selected directory.

easy-hugo-select-postdir

M-x easy-hugo-select-blog

Select blog you want to go. You can go to a selected blog.

easy-hugo-select-blog

M-x easy-hugo-complete-tags

Auto-complete tags from your past posts.

easy-hugo-complete-tags

M-x easy-hugo-complete-categories

Auto-complete categories from your past posts.

easy-hugo-complete-categories

M-x easy-hugo-current-time

Generate current time in date format at the frontmatter.

M-x easy-hugo-nth-blog

You can move to a blog with the specified number.

M-x easy-hugo-image
M-x easy-hugo-figure

Generate link of image from image file directory under 'static' directory.

easy-hugo-image1

When you select the image file you want to use, a link will be inserted. The default for the image file directory name is "images", but if you want to change it, write as follows.

(setq easy-hugo-image-directory "img")

easy-hugo-image2

M-x easy-hugo-put-image
M-x easy-hugo-put-figure

Move image to 'easy-hugo-image-directory' and generate image link. You can change the initial launch position with 'easy-hugo-default-picture-directory'.

easy-hugo-put-image

easy-hugo-put-image2

M-x easy-hugo-pull-image
M-x easy-hugo-pull-figure

Pull image from internet to image directory and generate image link. Copy the URL of the image you want to download with your browser. Execute M-x easy-hugo-pull-image.

easy-hugo-pull-image

Decide file name. If you press enter without deciding the file name, the file name can be used as it is.

easy-hugo-pull-image1

The file is saved in 'easy-hugo-image-directory' and generate image link.

easy-hugo-pull-image2

Commands for easy-hugo-mode

key function
RET easy-hugo-open
Tab easy-hugo-full-help
Shift-Tab easy-hugo-no-help
SPC easy-hugo-next-line
Shift-SPC easy-hugo-previous-line
easy-hugo-backward-char
easy-hugo-forward-char
C-b easy-hugo-backward-char
C-f easy-hugo-forward-char
C-n easy-hugo-next-line
C-p easy-hugo-previous-line
M-b easy-hugo-backward-word
M-< easy-hugo-beginning-of-buffer
. easy-hugo-next-postdir
, easy-hugo-previous-postdir
+ easy-hugo-next-postdir
- easy-hugo-previous-postdir
/ easy-hugo-select-postdir
; easy-hugo-select-blog
< easy-hugo-previous-blog
> easy-hugo-next-blog
? describe-mode
! easy-hugo-cancel-firebase-deploy-timer
A easy-hugo-amazon-s3-deploy
B easy-hugo-firebase-deploy
C easy-hugo-google-cloud-storage-deploy
D easy-hugo-list-draft
F easy-hugo-full-help
G easy-hugo-github-deploy
H easy-hugo-github-deploy-timer
I easy-hugo-google-cloud-storage-deploy-timer
J easy-hugo-nth-blog
L easy-hugo-firebase-deploy-timer
M easy-hugo-magit
N easy-hugo-no-help
O easy-hugo-open-basedir
P easy-hugo-publish-clever
R easy-hugo-rename
S easy-hugo-sort-char
T easy-hugo-publish-timer
V easy-hugo-view-other-window
W easy-hugo-amazon-s3-deploy-timer
a easy-hugo-ag
b easy-hugo-cancel-github-deploy-timer
c easy-hugo-open-config
d easy-hugo-delete
e easy-hugo-open
f easy-hugo-select-filename
g easy-hugo-refresh
h easy-hugo-backward-char
i easy-hugo-cancel-google-cloud-storage-deploy-timer
j easy-hugo-next-line
k easy-hugo-previous-line
l easy-hugo-forward-char
m easy-hugo-cancel-amazon-s3-deploy-timer
n easy-hugo-newpost
o easy-hugo-open-other-window
p easy-hugo-preview
q easy-hugo-quit
r easy-hugo-refresh
s easy-hugo-sort-time
t easy-hugo-cancel-publish-timer
u easy-hugo-sort-publishday
v easy-hugo-view
w easy-hugo-newpost

Requirements

  • Emacs 25.1 or higher
  • hugo 0.25 or higher

Installation

You can install easy-hugo.el from MELPA with package.el (M-x package-install easy-hugo). Confirm that PATH passes from emacs to go. I recommend you are going to install exec-path-from-shell. I recommend you are going to install keychain-environment. Easy-hugo-ag needs the_silver_searcher. Easy-hugo-ag needs counsel-ag or helm-ag.

Sample Configuration

When you change setting, you need to restart emacs.

If you deploy your blog at your server.

(setq easy-hugo-basedir "~/bookshelf/")
(setq easy-hugo-url "https://yourblogdomain")
(setq easy-hugo-sshdomain "blogdomain")
(setq easy-hugo-root "/home/blog/")
(setq easy-hugo-previewtime "300")
(define-key global-map (kbd "C-c C-e") 'easy-hugo)

If you use use-package, please write them all in :init.

(use-package easy-hugo
:init
(setq easy-hugo-basedir "~/bookshelf/")
(setq easy-hugo-url "https://yourblogdomain")
(setq easy-hugo-sshdomain "blogdomain")
(setq easy-hugo-root "/home/blog/")
(setq easy-hugo-previewtime "300")
:bind ("C-c C-e" . easy-hugo))

If you want to use transient menu style, setting as follow and then call easy-hugo-menu

;; Directly setting
(setq easy-hugo-no-help t)
(easy-hugo-enable-menu)

;; Or with use-package
(use-package easy-hugo
:bind ("C-c C-k" . easy-hugo-menu)
:config
(easy-hugo-enable-menu))

transient

If you deploy your blog at amazon s3.

(setq easy-hugo-basedir "~/bookshelf/")
(setq easy-hugo-url "https://yourblogdomain")
(setq easy-hugo-amazon-s3-bucket-name "yourS3bucketname")

If you deploy your blog at google cloud strage.

(setq easy-hugo-basedir "~/bookshelf/")
(setq easy-hugo-url "https://yourblogdomain")
(setq easy-hugo-google-cloud-storage-bucket-name "yourGCPbucketname")

If you deploy your blog at github pages etc.

(setq easy-hugo-basedir "~/bookshelf/")
(setq easy-hugo-url "https://yourid.github.io"))

If you deploy your blog at firebase hosting.

(setq easy-hugo-basedir "~/bookshelf/")
(setq easy-hugo-url "https://yourproject.firebaseapp.com")
name description
easy-hugo-basedir Directory where hugo html source code is placed on your laptop or desktop
easy-hugo-url Url of the blog
easy-hugo-sshdomain Domain written in ~/.ssh/config
easy-hugo-root Root directory of hugo at your server
easy-hugo-previewtime Preview display time

If you want to change default easy-hugo-postdir. If not set the default easy-hugo-postdir will be "content/post". Easy-hugo will not start when easy-hugo-postdir doesn't exist.

(setq easy-hugo-postdir "content/posts")

If you use Academic theme.

(setq easy-hugo-postdir "content/home")

If you want to deploy hugo at Amazon S3, please install AWS CLI and set easy-hugo-amazon-s3-bucket-name. Please set up for with aws configure command if you are the first time aws command.

(setq easy-hugo-amazon-s3-bucket-name "your-amazon-s3-bucket-name")

If you want to deploy hugo at Google Cloud Storage, please install Google Cloud SDK and set easy-hugo-google-cloud-storage-bucket-name. Please set up for with gcloud auth login command if you are the first time gcloud command.

(setq easy-hugo-google-cloud-storage-bucket-name "your-google-cloud-storage-bucket-name")

When writing blog with org-mode at .org file or rst-mode at .rst file or web-mode at .html file, "C-c C-e" keys are duplicated so please use other keys.

If you want the default extension to be '.org'. If not set the default extension will be '.md'.

(setq easy-hugo-default-ext ".org")

If you want the default extension to be '.ad'. If not set the default extension will be '.md'.

(setq easy-hugo-default-ext ".ad")

If you want the default extension to be '.rst'. If not set the default extension will be '.md'.

(setq easy-hugo-default-ext ".rst")

If you want to change to No help-mode from startup.

(setq easy-hugo-no-help t)

If you want to set charactor-sort at s key. If not set the default s key will be sort time.

(setq easy-hugo-sort-default-char t)

If you want to sort article in order of creation from startup.

(setq easy-hugo--sort-char-flg nil)
(setq easy-hugo--sort-time-flg nil)
(setq easy-hugo--sort-publishday-flg 1)

If you want to customise color, write the following in the init.el or .emacs.

(defface easy-hugo-help-face
  `((((class color) (background light))
     ,@(and (>= emacs-major-version 27) '(:extend t))
     :bold t
     :foreground "your-hex-color"
     :background "your-hex-color")
    (((class color) (background dark))
     ,@(and (>= emacs-major-version 27) '(:extend t))
     :bold t
     :foreground "your-hex-color"
     :background "your-hex-color"))
  "Definition of help color."
  :group 'easy-hugo-faces)

In order to generate link of image from image file directory under 'static' directory, if you want to change image file directory that is under 'static' directory. If not set the default image file directory will be 'images'.

(setq easy-hugo-image-directory "img")

Setting the picture directory of your laptop or desktop, it is easy to execute M-x easy-hugo-put-image.

(setq easy-hugo-default-picture-directory "~/Pictures")

If you want to use org style header, set it as below.

(setq easy-hugo-org-header t)

Then it becomes the following header. If you want to expand its keywords, use either #+KEY: VALUE format to set a single value string or #+KEY[]: VALUE_1 VALUE_2 format to assign multiple values in a whitespace-separated list of strings.

 #+TITLE:  filename
 #+DATE:  2018-01-31T12:10:08-08:00
 #+DRAFT: nil
 #+CATEGORIES[]: nil nil
 #+TAGS[]: nil nil
 #+DESCRIPTION: Short description

Multiple blogs setting

When you change setting, you need to restart emacs.

;; Main blog
(setq easy-hugo-basedir "~/bookshelf/")
(setq easy-hugo-url "https://yourblogdomain")
(setq easy-hugo-sshdomain "blogdomain")
(setq easy-hugo-root "/home/blog/")
(setq easy-hugo-previewtime "300")
(define-key global-map (kbd "C-c C-e") 'easy-hugo)

(setq easy-hugo-bloglist
	;; blog2 setting
	'(((easy-hugo-basedir . "~/src/github.com/masasam/hugo2/")
	(easy-hugo-url . "http://example2.com")
	(easy-hugo-sshdomain . "myblogdomain")
	(easy-hugo-root . "/home/hugo/"))
	;; blog3 setting for aws s3
	((easy-hugo-basedir . "~/src/github.com/masasam/hugo3/")
	(easy-hugo-url . "http://example3.net")
	(easy-hugo-amazon-s3-bucket-name . "yourS3bucketname"))
	;; blog4 setting for google cloud strage
	((easy-hugo-basedir . "~/src/github.com/masasam/hugo4/")
	(easy-hugo-url . "http://example4.net")
	(easy-hugo-google-cloud-storage-bucket-name . "yourGCPbucketname")
	(easy-hugo-image-directory . "img"))
	;; blog5 setting for github pages
	((easy-hugo-basedir . "~/src/github.com/masasam/githubpages/")
	(easy-hugo-url . "https://yourid.github.io"))
	;; blog6 setting for firebase hosting
	((easy-hugo-basedir . "~/src/github.com/masasam/firebase/")
	(easy-hugo-url . "https://yourproject.firebaseapp.com"))))

If you use use-package, please write them all in :init.

(use-package easy-hugo
:init
;; Main blog
(setq easy-hugo-basedir "~/bookshelf/")
(setq easy-hugo-url "https://yourblogdomain")
(setq easy-hugo-sshdomain "blogdomain")
(setq easy-hugo-root "/home/blog/")
(setq easy-hugo-previewtime "300")
(define-key global-map (kbd "C-c C-e") 'easy-hugo)

(setq easy-hugo-bloglist
	;; blog2 setting
	'(((easy-hugo-basedir . "~/src/github.com/masasam/hugo2/")
	(easy-hugo-url . "http://example2.com")
	(easy-hugo-sshdomain . "myblogdomain")
	(easy-hugo-root . "/home/hugo/"))
	;; blog3 setting for aws s3
	((easy-hugo-basedir . "~/src/github.com/masasam/hugo3/")
	(easy-hugo-url . "http://example3.net")
	(easy-hugo-amazon-s3-bucket-name . "yourS3bucketname"))
	;; blog4 setting for google cloud strage
	((easy-hugo-basedir . "~/src/github.com/masasam/hugo4/")
	(easy-hugo-url . "http://example4.net")
	(easy-hugo-google-cloud-storage-bucket-name . "yourGCPbucketname")
	(easy-hugo-image-directory . "img"))
	;; blog5 setting for github pages
	((easy-hugo-basedir . "~/src/github.com/masasam/githubpages/")
	(easy-hugo-url . "https://yourid.github.io"))
	;; blog6 setting for firebase hosting
	((easy-hugo-basedir . "~/src/github.com/masasam/firebase/")
	(easy-hugo-url . "https://yourproject.firebaseapp.com"))))
:bind ("C-c C-e" . easy-hugo))

You can manage as many blogs as you like.

If you want to change markdown filename extension, please select md or markdown or mdown. Because only these three are supported by hugo. If not set markdown filename extension will be 'md'.

(setq easy-hugo-markdown-extension "markdown")

If you want to change asciidoc filename extension, please select ad or asciidoc or adoc. Because only these three are supported by hugo. If not set asciidoc filename extension will be 'ad'.

(setq easy-hugo-asciidoc-extension "asciidoc")

If you want to change html filename extension, please select html or htm. Because only these two are supported by hugo. If not set html filename extension will be 'html'.

(setq easy-hugo-asciidoc-extension "htm")

For spacemacs or evil-mode users

If you use spacemacs or evil-mode, see spacemacs-easy-hugo.

Support emacspeak

If you use easy-hugo with emacspeak.

(setq easy-hugo-emacspeak t)

Preparation for using this package

Install hugo See https://gohugo.io/

Quickstart Guide See https://gohugo.io/overview/quickstart/

Configuration file example

hugo.toml

hasCJKLanguage = true
theme="material-design"
baseurl = "https://example.com"
languageCode = "ja"
title = "PPAP blog"
MetaDataFormat = "toml"
paginate = 9
copyright = "© 2017 PPAP blog powered by Hugo"

[params]
blogurl = "https://example.com"
blogdomain = "example.com"
github = "your github user name"
twitter = "your twitter user name"
googleAnalyticsUserID = "UA-************"

archetypes/default.md

+++
categories = [""]
tags = [""]
title = "{{ replace .TranslationBaseName "-" " " | title }}"
date = "{{ .Date }}"
draft = false
+++

archetypes/default.org (If your hugo version is 0.25 or higher)

+++
categories = [""]
tags = [""]
title = "{{ replace .TranslationBaseName "-" " " | title }}"
date = "{{ .Date }}"
draft = false
+++

archetypes/default.ad

+++
categories = [""]
tags = [""]
title = "{{ replace .TranslationBaseName "-" " " | title }}"
date = "{{ .Date }}"
draft = false
+++

archetypes/default.rst

+++
categories = [""]
tags = [""]
title = "{{ replace .TranslationBaseName "-" " " | title }}"
date = "{{ .Date }}"
draft = false
+++

archetypes/default.mmark

+++
categories = [""]
tags = [""]
title = "{{ replace .TranslationBaseName "-" " " | title }}"
date = "{{ .Date }}"
draft = false
+++

archetypes/default.html

+++
categories = [""]
tags = [""]
title = "{{ replace .TranslationBaseName "-" " " | title }}"
date = "{{ .Date }}"
draft = false
+++

Prepare the server

Let's build with a free trial of "google compute engine" or "amazon ec2". If you want deploy hugo at GitHub Pages or Amazon S3 or Google Cloud Storage, This paragraph is not necessary. I created my blog in google compute engine. Check if rsync is installed on the server.

Write at ~/.ssh/config on your laptop or desktop.

 Host blogdomain
     HostName "Your server's IP"
     User "Your server's ssh login username"

Because blog is generated under /home/blog/ on the server, set it to reference it with nginx. SSL uses certbot (Let's encrypt).

sample nginx.conf

server {
	listen 80;
	server_name yourdomain;
	return  301 https://yourdomain$request_uri;
	location / {
		root /home/blog;
	index	index.html index.htm;
	}
}
server {
	listen 443;
	server_name yourdomain;
	ssl on;
	ssl_certificate      /etc/letsencrypt/live/yourdomain/fullchain.pem;
	ssl_certificate_key  /etc/letsencrypt/live/yourdomain/privkey.pem;

location / {
	root    /home/blog;
index   index.html index.htm;
	}
}

PPAP source sample for hugo.

https://github.com/masasam/PPAP

emacs-easy-hugo's People

Contributors

cescoferraro avatar heikkil avatar kandros avatar masasam avatar mrunhap avatar purcell avatar tastytea avatar trevoke avatar ttybitnik 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

emacs-easy-hugo's Issues

What about a Set Date to Now option?

Sometimes it takes a while between starting a post and publishing it and I forget to fix the date so that it reflects the actual publish time.

I would love an easy way to set a post's date to now. Something similar to the way easy-hugo-undraft works but it would update the date: (and probably lastmod:) in the frontmatter to the current date/time.

.org header

When I use .org file to create a post, the header does not follow my default.md file in the archetype folder.
New posts made in .md have all from the default.md and a description tag as well.
Would it be possible to make the new posts follow the default.md suggestions ?

Have had a look at the code and found that it was hard-coded so I have changed it and recompile the package for my need. However, I will need to do that on every update.
Maybe you should add the author and categories entries as most blogs use it.
Thanks
obrow

How about exporting org to markdown in emacs

Hi, hugo's org support is quite fragile. It doesn't export source code blocks or tables correctly. I wonder if we can automatically convert org to markdown and use that as hugo's input file.

deploy.sh?

Hi,
I'm stumped about the deploy.sh part. The link about the password thing goes to a really old post. Plus, is it even deploy.sh anymore? Cuz I set mine up with .github/workflows/hugo.yaml ? As it says in https://gohugo.io/hosting-and-deployment/hosting-on-github/

So my question is: what do I do for deploy.sh? Is there a config I can copy/paste/edit? I'm really confused. I want to use easy-hugo because then I can write in org-mode instead of markdown. But it won't deploy at all so I don't know what to do.

Thx for any help.

Feature Request : Autocomplete for Categories and Tags

I always keep forgetting the exact categories and tags used in previous post(s)

Sometimes, it is obvious, but a lot of times it is not.

Is is possible to provide auto-complete for the categories and tags ?

This could be done during the "New Post" where you ask for the filename.

Unclear how to separate drafts from posts

Hello!

Thank you for this amazing tool. I have a few questions:

  1. Will drafts and posts be picked up in all subdirectories under the content directory?
  2. If I use the org-header, what is the header for a draft? Is it #+DRAFT: true ? or #+DRAFT: yes ? Or .. both .. or .. something else?
  3. Will drafts show up both in the list of drafts and in the list of posts?
  4. How do I help you test this if you need me to?

Error: Did you execute hugo new site bookshelf?

Hello,

I believe that the error message: Did you execute hugo new site bookshelf? is misleading, it took me a while to figure out that I had just mistyped the variable easy-hugo-basedir. The error pops out when the folder easy-hugo-basedir + content/posts doesn't exist, and I think that this should be the content of the error message.

Bye,
Sbozzolo

Using `require` is better to check `helm-ag` or `counsel` installed or not

Now using package-installed-p but it can support users who install packages via package.el.

emacs-easy-hugo/easy-hugo.el

Lines 1163 to 1167 in 3b0516c

(if (package-installed-p 'counsel)
(counsel-ag nil (expand-file-name easy-hugo-postdir easy-hugo-basedir))
(if (package-installed-p 'helm-ag)
(helm-ag (expand-file-name easy-hugo-postdir easy-hugo-basedir))
(error "'counsel' or 'helm-ag' is not installed")))))

This doesn't support those who use Cask, el-get, etc.
Is it better to use require instead of package-installed-p?

(defun easy-hugo-ag ()
  "Search for blog article with counsel-ag or helm-ag."
  (interactive)
  (easy-hugo-with-env
   (if (require 'counsel nil t)
       (counsel-ag nil (expand-file-name easy-hugo-postdir easy-hugo-basedir))
     (if (require 'helm-ag nil t)
	 (helm-ag (expand-file-name easy-hugo-postdir easy-hugo-basedir))
         (error "'counsel' or 'helm-ag' is not installed")))))

"\<\>": pattern not found error when invoking new-post

Hello,

I'm relatively new to Emacs, so my knowledge on these types of issues is relatively limited. So I apologize if this is not really an easy-hugo issue at all.

I'm currently using the Spacemacs distribution of emacs and have installed easy-hugo as an additional package. When I launch easy-hugo mode and type n for a new blog-post, I get the following error:

user-error: "\<\>": pattern not found

However, I have not been able to trace this issue further due to a few problems:

  • I've tried debugging easy-hugo-newpost by selecting the function in M-x debug-on-entry. However, the error occurs even before the function is called.

  • Using w as the shortcut for hugo-newpost works fine and does not generate the same error.

  • The above error occurs irrespective of me using Emacs mode or Evil mode in Spacemacs.

Does anyone have any suggestions on how I can trace this issue further?

easy-hugo config

  ;; Configure easy-hugo
  (with-eval-after-load 'easy-hugo
    (setq easy-hugo-basedir "f:/Balaji/Development/notebook/"
          easy-hugo-server-flags "-D"
          easy-hugo-postdir "content/posts"
          easy-hugo-image-directory "static/img"
          easy-hugo-url "https://nb.balaji.blog"
          easy-hugo-preview-url "http://127.0.0.1:1313/"
          )
    ;; (add-hook 'easy-hugo-mode-hook 'my-private-layer/easy-hugo)
    )

System Info

  • OS: windows-nt
  • Emacs: 26.3
  • Spacemacs: 0.300.0
  • Spacemacs branch: develop (rev. 72f280dc0)
  • Graphic display: t
  • Distribution: spacemacs
  • Editing style: vim
  • Completion: helm
  • Layers:
(rust javascript html helm auto-completion emacs-lisp git
      (markdown :variables markdown-command "pandoc -t html5 -f markdown_mmd --mathjax --quiet --highlight-style=pygments --template template/github.html5 --css template/github.css" markdown-live-preview-engine 'pandoc)
      (org :variables org-enable-hugo-support t)
      (shell :variables shell-default-shell 'eshell shell-default-height 30 shell-default-position 'bottom)
      spell-checking emoji shell-scripts windows-scripts yaml dash chrome nginx
      (deft :variables deft-zetteldeft t)
      multiple-cursors windows-defaults my-private-layer)
  • System configuration features: XPM JPEG TIFF GIF PNG RSVG SOUND NOTIFY ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS MODULES THREADS LCMS2

Path to Hugo binary

How to specify different Hugo binaries for different blogs (for example if I they require different versions or I do not want to place hugo in PATH)?

Change postdir of a specific blog

I'm using emacs-easy-hugo with multiple blog,
and postdir setting is used by default.

However, I'd like to change postdir setting for specific one blog.
Give me a hint on how to deal with it.

When easy-hugo-newpost in evil-mode, open with evil-insert-state

Thanks for providing us with a great script.

By the way, I recently installed evil-mode.
I had some key-bind conflicts, but I have it set up as follows and it works fine.

(add-to-list 'evil-emacs-state-modes 'easy-hugo-mode)

However, only easy-hugo-newpost opens files with evil-nomal-state,
so I redefined the configuration file to open files with
evil-insert-state by adding the following command.

(defun easy-hugo-newpost (post-file)
((...
(when (get-buffer "*hugo*")
  (kill-buffer "*hugo*"))
(find-file filename)
(when evil-mode
  (evil-insert-state))
(goto-char (point-max))
(save-buffer))))

It is never a request for updete, just a report of one evil user.
Thank you very much.

easy-hugo--version() crashed.

hugo version :
("hugo" "v0.81.0+extended" "darwin/amd64" "BuildDate=unknown")

Debug:
Debugger entered--Lisp error: (wrong-type-argument arrayp nil)
substring(nil 1)
(string-to-number (substring (nth 4 source) 1))
(let ((source (split-string (let ((temp-buffer (generate-new-buffer " temp" t))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn ...) (and ... ...)))) " "))) (string-to-number (substring (nth 4 source) 1)))
easy-hugo--version()
(progn (easy-hugo--version))

Do not delete other folders/files in top level destination when syncing

I have other folders in the top-level directory of the destination wehre I want to publish my blog. When I sync with the provided command, it will delete all files in the directory. What I would like is that only those files that are touched by hugo itself. rsync provides this capability when globbing (* operator) the source files. This means that there might be orphaned files created by hugo in the top-level directory, but I think the trade-off is worth it, as it prevents the surprised of finding unrelated files in the same directory deleted.

I have pasted a patch created with git format-patch.

From 023140b71cf1d1f98774405cd6628c9a848f3cc7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Niklas=20B=C3=B6hm?= <[email protected]>
Date: Thu, 4 Jan 2018 03:20:48 +0100
Subject: [PATCH] Do not delete other top level dirs in sync folder

---
 easy-hugo.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/easy-hugo.el b/easy-hugo.el
index 9e0537f..d3c607a 100644
--- a/easy-hugo.el
+++ b/easy-hugo.el
@@ -453,7 +453,7 @@ Report an error if hugo is not installed, or if `easy-hugo-basedir' is unset."
        (error "'hugo --destination public' command does not end normally")))
    (when (get-buffer "*hugo-publish*")
      (kill-buffer "*hugo-publish*"))
-   (shell-command-to-string (concat "rsync -rtpl --chmod=" easy-hugo-publish-chmod " --delete public/ " easy-hugo-sshdomain ":" (shell-quote-argument easy-hugo-root)))
+   (shell-command-to-string (concat "rsync -rtpl --chmod=" easy-hugo-publish-chmod " --delete public/* " easy-hugo-sshdomain ":" (shell-quote-argument easy-hugo-root)))
    (message "Blog published")
    (when easy-hugo-url
      (browse-url easy-hugo-url))))
--
2.15.1

How to handle page bundles?

Subject pretty much says it all. I like keeping images and stuff together with the post itself, instead of inflating the static directory.

Page bundles do not show up on the list of posts, however. It seems I can sort of switch around using the + and - keys, but I guess that is not the intended use of those functions? Also, that way I see either the flat posts, or the page bundles, but never both (i.e. it is hard to keep an overview of all posts).

Any hints appreciated.

Questions about configuring multiple blogs

Thanks for creating this!

I am puzzled about configuring multiple blogs. I tried adding a second one as described in the README:

 ;; Main blog
(setq easy-hugo-basedir "~/bookshelf/")
(setq easy-hugo-url "https://yourblogdomain")
(setq easy-hugo-sshdomain "blogdomain")
(setq easy-hugo-root "/home/blog/")
(setq easy-hugo-previewtime "300")
(define-key global-map (kbd "C-c C-e") 'easy-hugo)

(setq easy-hugo-bloglist
	;; blog2 setting
	'(((easy-hugo-basedir . "~/src/github.com/masasam/hugo2/")
	(easy-hugo-url . "http://example2.com")
	(easy-hugo-sshdomain . "myblogdomain")
	(easy-hugo-root . "/home/hugo/"))))

However, using the > and < keys to go back and forth between them doesn't work. From a quick look at the code, it seems that if easy-hugo-bloglist is defined, the configuration is only updated when there is more than one blog in that list, and it works if I add another entry like blog3 in the example.

When I do have the 3 blogs defined, < does not go back to the original one.

Make it possible to manage an unlimited number of blogs

Unlimited blogs can not be managed with the settings below.
Example of init.el
easy-hugo-basedir-1 ~ easy-hugo-basedir-9

So I'm going to update easy-hugo so that it works with complete lists of settings.
Example of init.el

(setq easy-hugo-bloglist '(((easy-hugo-basedir . "/home/masa/ppap") (easy-hugo-url . "http://example.com")) ((easy-hugo-basedir . "/home/masa/ppap1") (easy-hugo-url . "http://example.org")) ((easy-hugo-basedir . "/home/masa/ppap2") (easy-hugo-url . "http://example.net"))))

ai-blog.el

Hey there!

Just to drop this here in case anyone is interested.

I blog with Emacs and easy-hugo, and wanted to integrated some AI-assisted helper functions to help me speed up my blogging, using gptel.

https://github.com/kamushadenes/ai-blog.el

I'll add new stuff as I come across ideas.

Thanks for this amazing project!

I cannot understand the documentation at all

This is a very general comment, but I used a similar package, Org2Blog, and it was not hard to understand it with some effort. emacs-easy-hugo may truly be easy, but I have no idea how to interpret large portions of the documentation. There are no actual examples, and I might need to devote a lot of time of mindless guesswork just to make it work. The idea is good, but the lack of organized documentation makes me think that I would be better suited by writing straight to markdown and using the command line.

If you really want more people to use this, I suggest you spend more time with the documentation and less time coding - at least for a while.

At this point, I'm giving up.

Thanks anyway.

Publish time for displaying posts

@masasam ,
Thank you for your work with easy-hugo. It has really made working with hugo and org-mode a breeze.

I would like to find out if there is an option to sort the order of the published posts with the date of publishing rather than file creation/modification date?

If it is not there currently, can I please request you to treat this as a feature request?

Thanks again for the exemplary work
Bala

org-header not used when executing easy-hugo-newpost

I am running in spacemacs and it seems to really break easy-hugo so I am not using that main menu yet.

I am running hugo 0.31 and I use .org as the default file extension. easy-hugo-newpost does initialize a new post but it does not use the org header.

ftp publishing?

First of all: many thanks for making easy-hugo! Just what I needed.

I have a question on how publishing works. The documentation is extremely terse, to be frank.

My site is on a shared web hosting, and I need to upload it via ftp. Thus, after generating the pages with Hugo, I would need a shell script to be called, which does the ftp upload.

From what I understood, I should probably be using easy-hugo-github-deploy and craft my own deploy.sh for this scenario?

images with posts and/or bundle

Hello,

I like to put images which are part of the post in a dedicated folder, iow. something like:

test.md
test
└── myviber.jpg

which allows me to reference the image within test.md as:

{{< figure src="myviber.jpg" alt="My Viber" class="center" >}}

so I wonder what do you think about adding support for that?

Moreover, newer versions of Hugo also support bundles with the same/similar functionality, so the same question about support for that in Easy Hugo?

support for AsciiDoc(tor)/reS formats

Hello,

thank you for very interesting package!

Considering I plan to use AsciiDoc(tor) markup with Hugo, what do you think to extend the package by adding support for AsciiDoc(tor)/reST markup formats?

Rendered Checkboxes?

Hi again, I'm sorry to bother you once more.
I'm trying to get org-mode checkboxes to render on my site, but they aren't. Instead of checkboxes at the start of every list item, they come out as little dots when they are exported. I'm not sure if that's easy-hugo's exporter or something else?

Please let me know if I'm doing something wrong? I'm just exporting an org-mode list of movies I've watched but the checkboxes definitely aren't exporting like they would from org-mode.

Thanks! Sorry again for the bother.

css rights

First, your package is amazing !
When I push the public directory to the server, (P) everything is created and pushed correctly except that the rights on the CSS directory become drwx------ and only for this directory. The website can't access the css folder.
If I take the public directory generated by easy-hugo and send it with my sftp client, the rights are drwxr-xr-x.
The rights are changing during the upload through the P command.
changing the rights manually makes the website work again correctly.
Thank you.

How to pass password to deploy.sh?

Hello.

I have a blog on the github pages and I use this script for deployment:

#!/bin/bash

echo -e "\033[0;32mDeploying updates to GitHub...\033[0m"
hugo 

cd public
git add -A

msg="rebuilding site `LANG=C date`"
if [ $# -eq 1 ]
  then msg="$1"
fi
git commit -m "$msg"

git push origin master

cd ..

In the script git push command prompts for a ssh password in the console, but easy-hugo not request a password and therefore no changes are made to the server.

Is it possible to somehow request a password inside easy-hugo when deploying?

Error when using easy-hugo-next-postdir

Hi,

After trying to hack together my own solution for posting to multiple folders in /content I found that you had already implemented easy-hugo-next-postdir which I think is exactly what I want.

However, when calling either easy-hugo-next-postdir or easy-hugo-prev-postdir I get the following:

helm-M-x: Lisp nesting exceeds ‘max-lisp-eval-depth’

This happens regardless of whether I have easy-hugo-postdir set or not. Here's what /content looks like...

.
├── lifestack
├── micro
│   └── 2017
└── post
    ├── 2000-2015
    ├── 2016
    ├── 2017
    └── 2018
        └── 2018-05-24_hugo-bundles

And here's my config:

  (setq easy-hugo-basedir "~/Sync/sites/blog/"
        easy-hugo-postdir "content/post"
        easy-hugo-image-directory "img/2018"
        easy-hugo-url ""
        easy-hugo-preview-url "http://localhost:1313/"
        easy-hugo-sshdomain ""
        easy-hugo-root ""
        easy-hugo-default-ext ".md"
        easy-hugo-default-picture-directory "~/tmp/outbox"
        easy-hugo-previewtime "300")

Emacs 26.1 and spacemacs (develop branch: f1f8db002af108f58c9a78c5286e8beca59af6de)

Single blog many folders

Hello,

I would like to use easy-hugo to manage my academic website, which is based on the academic hugo theme (https://github.com/gcushen/hugo-academic). In this theme there are many folders that contain content, ie one for posts, one for talks, and so on. Is there a way to manage this structure with easy-hugo?

I thought I could define many blogs with different postdirs. This requires a little tweaking in the source code but it is easily doable. Nonethless, I don't think it is a sleek solution. It would be nice if easy-hugo implemented directly the capability of switching post folder as it already does with swtiching blogs.

With regards,
sbozzolo

Github deploy bug

Hello @masasam,
I absolutely love the ease of using easy-hugo. I, now, use your package with 4 hugo based websites 😄 . Thanks for your hard work.

I never tried using the Github deploy, but recently, I felt like experimenting with it. But when I tried, the entire path had a space in it and the error I got was always No such file or directory... <mypath>/deploy.sh

Recently, I found out that when the path did not have a space in it, then it worked fine.

Example, my path had the folder by name Our Websites. I renamed this to Websites and it started working fine.

Thanks and have a good day!
Bala

I can't move to next blog when there is only 1 blog in easy-hugo-bloglist.

Hi,
I am using easy hugo for some years.
I really like it.

The follwing code will do nothing when there is only 1 blog in easy-hugo-bloglist.
(defun easy-hugo-next-blog () "Go to next blog." (when (< 1 (length easy-hugo-bloglist)) (if (eq (- (length easy-hugo-bloglist) 1) easy-hugo--current-blog) (setq easy-hugo--current-blog 0)

In that case,
(length easy-hugo-bloglist)
return 1 and exit the function.

Should it be either of the following code?

(boundp 'easy-hugo-bloglist)
or
(when (< 0 (length easy-hugo-bloglist))

Well, I am trying to fix this issue but haven't got good solution.

Publish date in the list of posts

Hello @masasam,
Thanks for the wonderful package easy-hugo.

I have a feature request to make:
Listing the publishing date of the posts in the list (#39 dealt with sorting, however a listing would also help, I think)

Thanks again for your wonderful work
Have a good day!
Bala

Emacs hangs after running easy-hugo-newpost

I'm not sure when this started, but when calling easy-hugo-newpost (20181022.833 in Emacs 26.1.1) hangs, requiring me to force quit (macOS). Steps:

  1. Start easy-hugo
  2. Run easy-hugo-newpost
  3. Type a filename (e.g. myfile.md)
  4. Hit return

At this point, Emacs (gui, macOS) becomes unresponsive. The new file is created correctly, though. Not sure how to help debug this, but let me know if there's anything I can do.

Jack

rsync (command does not end normally)

Thank you very much for easy-hugo it is a pleasure to use it !

hugo version : 0.69.2
emacs version: 26.3
orgmode version: 9.3.6

When pushing the blog, everything seems to work perfectly but I get an error report with rsync.

Debugger entered--Lisp error: (error "’rsync’ command does not end normally")
  signal(error ("’rsync’ command does not end normally"))
  error("'rsync' command does not end normally")
  easy-hugo-publish()
  easy-hugo-publish-clever()
  funcall-interactively(easy-hugo-publish-clever)
  #<subr call-interactively>(easy-hugo-publish-clever nil nil)
  apply(#<subr call-interactively> easy-hugo-publish-clever (nil nil))
  call-interactively@ido-cr+-record-current-command(#<subr call-interactively> easy-hugo-publish-clever nil nil)
  apply(call-interactively@ido-cr+-record-current-command #<subr call-interactively> (easy-hugo-publish-clever nil nil))
  call-interactively(easy-hugo-publish-clever nil nil)
  command-execute(easy-hugo-publish-clever)

I don't know if it is related to easy-hugo or not. It is unclear for me so I am just asking if you could help with that.

Thank you.

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.