I got a static file hosted in /static directory, with the following relative URL to base URL:
/css/bissetii-amp-1-12-4.min.css
Note:
Need not to worry about the version numbering since there is a data processor handles them seamlessly. For simplicity sake, let’s lock it to 1-12-4.
Reason To Do This:
For deploying AMP styling. AMP prohibits users to link a CSS file externally and must embed the contents inside <style amp-custom> tag.
The generated CSS file is mainly for distributing the AMP CSS codes as it is for deployment outside Hugo and Go. It makes no sense to distribute a .html file since user may concat the CSS with his/her own codes.
I’m working in a theme module that is also a CSS framework.
Makes no sense to store the CSS artifact inside /content relative path as there are other sibling like bissetii-main-1-12-4.min.css that caters normal HTML usage using conventional link tag. All of them are stored systematically inside /static/css directory. Also, the multi-language is enabled by default.
Currently, I’m able to duplicate it into /layout/partials but that means there will be duplicates, with minimum of 2 amp CSS file in the repository, per version release.
I tried ReadFile and apparently, it cannot read upper path (e.g. ../static/css/bissetii-amp-1-12-4.min.css). Also, it is relative to the project level directory and not theme level directory so it is very risky to use ReadFile.
Noted. Will explore somewhere in Q4 2020. This feature is useful for both Hugo sites and theme module hosted in same repository (the first patient: data/ directory).
For now, I will keep the solution first (mainly because I tested it).