Deploying hugo to gitlab Pages with Hokus CMS , real date and a custom footer
first a lot of playing was necessary to see that
-
Hokus writes posts in
content/posts/postname/index.md
( whereas e.g. Lipi just createscontent/posts/postname.md
) -
Hokus might not properly import your theme so you might manually edit
config.toml/yaml
A custom footer was enabled by creating layouts/partials/extended_footer.html
and just inserting custom HTML code
Search engines were added by putting BingSiteAuth.xml
and google123456789abcde.html
and yandex_123456789abcde.html
into the /static
folder
The og:image
and favicon was adjusted by inserting the following lines in config.toml:
cover = "images/yourimage.png"
favicon = "images/yourimage.png"
to make google and other search images display a text that is NOT the text of the most recent post,
a file called content/_index.md
had to be created
since the use of raw html was partially necessary ( to make logo appear ), [this tutorial](https://anaulin.org/blog/hugo-raw-html-shortcode/ Hugo Shortcode howto) was applied by:
mkdir layouts/shortcodes/
and then creating layouts/shortcodes/rawhtml.html
with the following content:
<!-- raw html -->
{{.Inner}}
so one could use the following in the content/_index.md
file
+++
framed = true
+++
{ { < rawhtml >}}
<div style="float: right">
{ {< /rawhtml >}}
![Bash-Stack Logo ](/images/b4sh-st4ck-66px.png)
{ {< rawhtml >}}
</div>
{ {< /rawhtml >}}
#### The place for all common bash problems and b4sh-l1b !
(the space between { {
is not used in the real file )
since Hokus fails to insert a real ISO8601 timestamp in current version (2020-10) instead of just a simple date, “fix-pubdate.sh” script was introduced:
#!/bin/bash
for post in $(grep -rl "^pubdate" content/posts |grep md$);do
echo Verifying date of ${post} ;
##check for short pubdate
if [ $(grep ^pubdate ${post}|wc -c) -lt 25 ];then
echo fixing ${post};
test -f ${post}.pubdate && datestring=$(cat ${post}.pubdate );
test -f ${post}.pubdate || datestring='pubdate = "'$(date -r ${post} "+%m-%d-%Y %H:%M:%S")'"';
test -f ${post}.pubdate || ( echo no pubdate file..creating ;echo $datestring > ${post}.pubdate );
sed 's/^pubdate.\+/'$datestring'/g' -i "${post}"
else
echo valid pubdate in ${post};
test -f ${post}.pubdate || ( echo no pubdate file ..creating ;grep ^pubdate ${post} > ${post}.pubdate );
fi;
done
the .gitlab-ci.yml
had to be modified:
image: registry.gitlab.com/pages/hugo/hugo_extended
variables:
GIT_SUBMODULE_STRATEGY: recursive
pages:
script:
- apk add bash
- /bin/bash -c "bash fix-pubdate.sh"
- hugo
artifacts:
paths:
- public
only:
- master