gmagno
gmagno

Reputation: 2000

How to align-center an image/figure with Hugo (go static site generator)?

I am looking for a solution that works with hugo server command. I am aware that I could create an additional .css file inside static/css directory and have it merged into the public directory with hugo command, however that does not work with hugo server unfortunately.

Thanks in advance.

Upvotes: 2

Views: 2431

Answers (1)

VonC
VonC

Reputation: 1324787

On Hugo Pipes, you have an example with "Hugo Pipes Revolution -- A Hugo built-in asset pipeline" from Regis Philibert to give some examples.

From now on, Hugo will take care of bundling, minifying, fingerprinting our assets and even compiling our sass files! All of this without any external build tools.

So it works with hugo server.
You can define your method in assets:

These methods will only be available on files living in the assets directory: think of it as a static directory except the files will not be published by default.

Much like its static counterpart:

  • Its location is configurable with the assetDir key of your config.yaml. (will default to assets)
  • It follows the Hugo’s file unison logic.
    Meaning, anything in your project/assets will override homonymous files of your theme/assets.

From there, you can adapt one of the sass centering techniques to apply it automatically on your images using pipes.
See "Centering With Sass".

Upvotes: 1

Related Questions