Site logo

Archived topic

How to make a html anchor in my blog

21 replies · Started by Max on January 22, 2022

Viewing posts 1–15 of 22

Hi check this link out https://imu.nl/de-chronologische-feed-van-instagram-komt-terug/

I want the same as they have in the left sidebar. If you press on it that you go to that headertext.

I get i need to do it with HTML anchor and Smooth scroll.

Only thing is that i don´t know how this automaticly goes.

So that everytime i upload a H2 header that it will appear in the left sidebar

Hi David, last time Ying said in the following link https://generatepress.com/forums/topic/dynamic-feature-image-doesnt-change/

This:

can achieve this using a block element (inside_left_sidebar hook), the links would be HTML anchor, assign the block element to post >all posts in location.

This video introduced how to use HTML anchor: https://www.youtube.com/watch?v=f_OaAiJ3oV4&t=176s&ab_channel=GeneratePress

I would suggest using custom field to store the HTML anchors, so they can be pulled dynamically.

In this video you can see how to pull the value from custom field: https://www.youtube.com/watch?v=H6wHd83DfDI&t=57s&ab_channel=GeneratePress

Would that also be possible? It is just that i don´t get the custom field part.

How can i put the table in the left side bar? I thought this is the good widget name

So you are using a table of content plugin?

I'm not familiar with the plugin, can't guide you through on this.

If there's a widget of this plugin, you should be able to add the widget at appearance > widgets.

I understand but there is a field ´widget affix selector´ and that field say.

´´To enter the option to apply or pin the Table of Contents widget, enter the theme's sidebar class or ID.
Because every theme is different, this cannot be determined automatically. If you're not sure how to find the sidebar's class or id, ask the theme's supporters.
For example: .widget area or #sidebar´´

So what is the sidebar class or ID?

Ah that's what you mean, in that case, use inside-left-sidebar for widget affix selector is correct.

I prefer not to use the easy table of content plugin. Just the custom fields like you explained. I know how to enable the custom field. But what do i need to fill-in in the custom field as value?

How many posts are you going to have that will require a Table of Contents ?

Because to do this using Custom Fields you will need to:

1. Manually add a #HTML anchor to each of the linked headings.
2. Register a Custom Field for each of those anchors to contain the anchor link eg. Heading-link-1, Heading-link-2 etc.
3. Register a Custom Field for the Text for each of those links eg. Heading-text-1, Heading-text-2 etc.

So if you got 10 headings - thats 20 custom fields.

And if you have many posts that a lot of fields to maintain.
And if one post has more headings tahn another, you still gonna register a Block Element with the Largest possible number of custom fields whether they are used or not.

Which is why i would recommend using a plugin as it does all that stuff for you - and if in the future you want to remove that from all your posts you just uninstall the plugin.

Every week 1 post

Hmmm okay,
Cause i read that easy table of contents give a higher CLP. But if you say this is the best solution i trust you thanks!

Performance wise i haven't see it have a big impact on LCP. Ultimately i think what little impact it may have will be outweighed by how much easier it will be to run the site.

Glad to be of help.

I contacted Toc and they said i had to ask you guys how to add the widget in my left side bar.

This archived topic is closed to new replies.