GetPublii / Publii

The most intuitive Static Site CMS designed for SEO-optimized and privacy-focused websites.
https://getpublii.com
GNU General Public License v3.0
6.06k stars 407 forks source link

[Feature Request]: Option to Add Custom Meta Tags or Scripts in <head> Per Post #1231

Closed kmanadkat closed 11 months ago

kmanadkat commented 11 months ago

Feature Description

I want to add custom meta tags & JSON-LD scripts for SEO. This can differ post by post, so hardcoding in Theme might not be right.

Can we please have an option somewhere in the post settings sidebar, or anywhere it feels feasible?

Screenshot 2023-07-23 at 11 00 07 AM

Example content to add in (it can be other stuff too like additional meta tags):

Screenshot 2023-07-23 at 11 02 31 AM
bobmitro commented 11 months ago

You need to add a textarea via the Post Config option. More information can be found here: https://getpublii.com/dev/post-config-options/

kmanadkat commented 11 months ago

You need to add a textarea via the Post Config option. More information can be found here: https://getpublii.com/dev/post-config-options/

Cool, checking it. Thanks

kmanadkat commented 11 months ago

@bobmitro I tried cloning repository & following https://github.com/GetPublii/Publii/wiki/App-build-process

Seeing error:

Screenshot 2023-07-23 at 12 28 06 PM

macos Ventura v13 Node v16.20.0 Xcode v14.3.1

I tried rebuilding better-sqlite package by :

cd app/node_modules/better-sqlite3
npm install
npm run install  # strangely, package had install script
npm run rebuild-release

Restarted things in root of project:

npm run dev
npm run build # Another terminal tab

can you please help ?

kmanadkat commented 11 months ago

@bobmitro it worked, I misunderstood earlier. I just added below in config.json of theme

        {
            "name": "displayTextarea",
            "label": "Additional Head Tags",
            "value": "",
            "type": "textarea"
        },

Like how you suggested with the Post Config options link & added below in head.hbs

{{{@config.post.displayTextarea}}}
Screenshot 2023-07-23 at 2 25 15 PM

This solves the requirement, hence closing ticket.

Off the topic, do you happen to know by any chance if it is ok to have multiple "application/ld+json" script tags?

bobmitro commented 11 months ago

Off the topic, do you happen to know by any chance if it is ok to have multiple "application/ld+json" script tag

I think it's fine to have multiple JSON-LD data on a single page for example to represent different types of data.

kmanadkat commented 11 months ago

Thanks